Skip to content

Commit 38ba4dc

Browse files
committed
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 #5133)
1 parent 1c329c0 commit 38ba4dc

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/move.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ textpos2screenpos(
12171217
col -= rowoff * width;
12181218
}
12191219
col -= wp->w_leftcol;
1220-
if (col >= width)
1220+
if (col >= wp->w_width)
12211221
col = -1;
12221222
if (col >= 0)
12231223
coloff = col - scol + wp->w_wincol + 1;

src/testdir/test_cursor_func.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,18 @@ func Test_screenpos()
100100
close
101101
bwipe!
102102
endfunc
103+
104+
func Test_screenpos_number()
105+
rightbelow new
106+
rightbelow 73vsplit
107+
call setline (1, repeat('x', 66))
108+
setlocal number
109+
redraw
110+
let winid = win_getid()
111+
let [winrow, wincol] = win_screenpos(winid)
112+
let pos = screenpos(winid, 1, 66)
113+
call assert_equal(winrow, pos.row)
114+
call assert_equal(wincol + 66 + 3, pos.col)
115+
close
116+
bwipe!
117+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
2228,
744746
/**/
745747
2227,
746748
/**/

0 commit comments

Comments
 (0)