vim-patch:8.1.2228: screenpos() returns wrong values when 'number' is set

Problem:    screenpos() returns wrong values when 'number' is set. (Ben
            Jackson)
Solution:   Compare the column with the window width. (closes vim/vim#5133)
38ba4dce4a
This commit is contained in:
Jan Edmund Lazo 2020-05-17 17:33:27 -04:00
parent 63966a9ec2
commit 9cdea8148c
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 16 additions and 1 deletions

View File

@ -996,7 +996,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp,
col -= wp->w_leftcol; col -= wp->w_leftcol;
if (col >= 0 && col < width) { if (col >= 0 && col < wp->w_width) {
coloff = col - scol + (local ? 0 : wp->w_wincol) + 1; coloff = col - scol + (local ? 0 : wp->w_wincol) + 1;
} else { } else {
scol = ccol = ecol = 0; scol = ccol = ecol = 0;

View File

@ -93,3 +93,18 @@ func Test_screenpos()
close close
bwipe! bwipe!
endfunc endfunc
func Test_screenpos_number()
rightbelow new
rightbelow 73vsplit
call setline (1, repeat('x', 66))
setlocal number
redraw
let winid = win_getid()
let [winrow, wincol] = win_screenpos(winid)
let pos = screenpos(winid, 1, 66)
call assert_equal(winrow, pos.row)
call assert_equal(wincol + 66 + 3, pos.col)
close
bwipe!
endfunc