1
0
forked from aniani/vim

patch 8.2.4204: screenpos() has non-zero row for invisible text

Problem:    screenpos() has non-zero row for invisible text.
Solution:   Only add the window row when the text is visible. (closes #9618)
This commit is contained in:
Bram Moolenaar
2022-01-24 16:15:15 +00:00
parent 502d8ae3e8
commit 7924a17791
3 changed files with 7 additions and 2 deletions

View File

@@ -1262,12 +1262,15 @@ textpos2screenpos(
if (col >= wp->w_width) if (col >= wp->w_width)
col = -1; col = -1;
if (col >= 0 && row + rowoff <= wp->w_height) if (col >= 0 && row + rowoff <= wp->w_height)
{
coloff = col - scol + wp->w_wincol + 1; coloff = col - scol + wp->w_wincol + 1;
row += W_WINROW(wp);
}
else else
// character is left, right or below of the window // character is left, right or below of the window
row = rowoff = scol = ccol = ecol = 0; row = rowoff = scol = ccol = ecol = 0;
} }
*rowp = W_WINROW(wp) + row + rowoff; *rowp = row + rowoff;
*scolp = scol + coloff; *scolp = scol + coloff;
*ccolp = ccol + coloff; *ccolp = ccol + coloff;
*ecolp = ecol + coloff; *ecolp = ecol + coloff;

View File

@@ -124,7 +124,7 @@ func Test_screenpos()
\ 'col': wincol + 7, \ 'col': wincol + 7,
\ 'curscol': wincol + 7, \ 'curscol': wincol + 7,
\ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8)) \ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8))
call assert_equal({'row': winrow - 1, 'col': 0, 'curscol': 0, 'endcol': 0}, call assert_equal({'row': 0, 'col': 0, 'curscol': 0, 'endcol': 0},
\ winid->screenpos(line('$'), 22)) \ winid->screenpos(line('$'), 22))
close close

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4204,
/**/ /**/
4203, 4203,
/**/ /**/