mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Problem: screenpos() does not handle a position in a closed fold. Solution: Check if the position is inside a closed fold. (closes #9778)
This commit is contained in:
17
src/move.c
17
src/move.c
@@ -1239,8 +1239,22 @@ textpos2screenpos(
|
||||
colnr_T off;
|
||||
colnr_T col;
|
||||
int width;
|
||||
linenr_T lnum = pos->lnum;
|
||||
#ifdef FEAT_FOLDING
|
||||
int is_folded;
|
||||
|
||||
row = plines_m_win(wp, wp->w_topline, pos->lnum - 1) + 1;
|
||||
is_folded = hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL);
|
||||
#endif
|
||||
row = plines_m_win(wp, wp->w_topline, lnum - 1) + 1;
|
||||
#ifdef FEAT_FOLDING
|
||||
if (is_folded)
|
||||
{
|
||||
row += W_WINROW(wp);
|
||||
coloff = wp->w_wincol + 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
getvcol(wp, pos, &scol, &ccol, &ecol);
|
||||
|
||||
// similar to what is done in validate_cursor_col()
|
||||
@@ -1270,6 +1284,7 @@ textpos2screenpos(
|
||||
// character is left, right or below of the window
|
||||
row = rowoff = scol = ccol = ecol = 0;
|
||||
}
|
||||
}
|
||||
*rowp = row + rowoff;
|
||||
*scolp = scol + coloff;
|
||||
*ccolp = ccol + coloff;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
" Tests for cursor() and other functions that get/set the cursor position
|
||||
|
||||
source check.vim
|
||||
|
||||
func Test_wrong_arguments()
|
||||
call assert_fails('call cursor(1. 3)', 'E474:')
|
||||
call assert_fails('call cursor(test_null_list())', 'E474:')
|
||||
@@ -133,12 +135,27 @@ func Test_screenpos()
|
||||
bwipe!
|
||||
set display&
|
||||
|
||||
call assert_equal({'col': 1, 'row': 1, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1))
|
||||
call assert_equal(#{col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1))
|
||||
nmenu WinBar.TEST :
|
||||
call assert_equal({'col': 1, 'row': 2, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1))
|
||||
call assert_equal(#{col: 1, row: 2, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1))
|
||||
nunmenu WinBar.TEST
|
||||
endfunc
|
||||
|
||||
func Test_screenpos_fold()
|
||||
CheckFeature folding
|
||||
|
||||
enew!
|
||||
call setline(1, range(10))
|
||||
3,5fold
|
||||
redraw
|
||||
call assert_equal(2, screenpos(1, 2, 1).row)
|
||||
call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 3, 1))
|
||||
call assert_equal(3, screenpos(1, 4, 1).row)
|
||||
call assert_equal(3, screenpos(1, 5, 1).row)
|
||||
call assert_equal(4, screenpos(1, 6, 1).row)
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_screenpos_number()
|
||||
rightbelow new
|
||||
rightbelow 73vsplit
|
||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
4389,
|
||||
/**/
|
||||
4388,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user