mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Problem: screenpos() is wrong when the last line is partially visible and 'display' is "lastline". Solution: Also compute the position for a partially visible line. (closes #8599)
This commit is contained in:
parent
11d7e62f1d
commit
189663bdac
@ -1229,7 +1229,7 @@ textpos2screenpos(
|
|||||||
int rowoff = 0;
|
int rowoff = 0;
|
||||||
colnr_T coloff = 0;
|
colnr_T coloff = 0;
|
||||||
|
|
||||||
if (pos->lnum >= wp->w_topline && pos->lnum < wp->w_botline)
|
if (pos->lnum >= wp->w_topline && pos->lnum <= wp->w_botline)
|
||||||
{
|
{
|
||||||
colnr_T off;
|
colnr_T off;
|
||||||
colnr_T col;
|
colnr_T col;
|
||||||
@ -1256,11 +1256,11 @@ textpos2screenpos(
|
|||||||
col -= wp->w_leftcol;
|
col -= wp->w_leftcol;
|
||||||
if (col >= wp->w_width)
|
if (col >= wp->w_width)
|
||||||
col = -1;
|
col = -1;
|
||||||
if (col >= 0)
|
if (col >= 0 && row + rowoff <= wp->w_height)
|
||||||
coloff = col - scol + wp->w_wincol + 1;
|
coloff = col - scol + wp->w_wincol + 1;
|
||||||
else
|
else
|
||||||
// character is left or right of the window
|
// character is left, right or below of the window
|
||||||
row = scol = ccol = ecol = 0;
|
row = rowoff = scol = ccol = ecol = 0;
|
||||||
}
|
}
|
||||||
*rowp = W_WINROW(wp) + row + rowoff;
|
*rowp = W_WINROW(wp) + row + rowoff;
|
||||||
*scolp = scol + coloff;
|
*scolp = scol + coloff;
|
||||||
|
@ -101,9 +101,25 @@ func Test_screenpos()
|
|||||||
\ 'col': wincol + 9,
|
\ 'col': wincol + 9,
|
||||||
\ 'curscol': wincol + 9,
|
\ 'curscol': wincol + 9,
|
||||||
\ 'endcol': wincol + 9}, screenpos(winid, 2, 22))
|
\ 'endcol': wincol + 9}, screenpos(winid, 2, 22))
|
||||||
|
|
||||||
|
let wininfo = getwininfo(winid)[0]
|
||||||
|
call setline(3, ['x']->repeat(wininfo.height))
|
||||||
|
call setline(line('$') + 1, 'x'->repeat(wininfo.width * 3))
|
||||||
|
setlocal nonumber display=lastline so=0
|
||||||
|
exe "normal G\<C-Y>\<C-Y>"
|
||||||
|
redraw
|
||||||
|
call assert_equal({'row': winrow + wininfo.height - 1,
|
||||||
|
\ 'col': wincol + 7,
|
||||||
|
\ 'curscol': wincol + 7,
|
||||||
|
\ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8))
|
||||||
|
call assert_equal({'row': winrow - 1, 'col': 0, 'curscol': 0, 'endcol': 0},
|
||||||
|
\ winid->screenpos(line('$'), 22))
|
||||||
|
|
||||||
close
|
close
|
||||||
call assert_equal({}, screenpos(999, 1, 1))
|
call assert_equal({}, screenpos(999, 1, 1))
|
||||||
|
|
||||||
bwipe!
|
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 :
|
nmenu WinBar.TEST :
|
||||||
|
@ -755,6 +755,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 */
|
||||||
|
/**/
|
||||||
|
3193,
|
||||||
/**/
|
/**/
|
||||||
3192,
|
3192,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user