Skip to content

Commit f0e68c0

Browse files
zeertzjqbrammool
authored andcommitted
patch 9.0.1600: screenpos() does not take w_skipcol into account
Problem: screenpos() does not take w_skipcol into account. Solution: Subtract w_skipcol from column. (closes #12486, closes #12476)
1 parent a109f39 commit f0e68c0

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

src/move.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,9 @@ textpos2screenpos(
14791479
col += off;
14801480
width = wp->w_width - off + win_col_off2(wp);
14811481

1482+
if (pos->lnum == wp->w_topline)
1483+
col -= wp->w_skipcol;
1484+
14821485
// long line wrapping, adjust row
14831486
if (wp->w_p_wrap
14841487
&& col >= (colnr_T)wp->w_width

src/testdir/test_cursor_func.vim

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,40 @@ func Test_screenpos()
127127
\ 'curscol': wincol + 7,
128128
\ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8))
129129
call assert_equal({'row': 0, 'col': 0, 'curscol': 0, 'endcol': 0},
130-
\ winid->screenpos(line('$'), 22))
130+
\ winid->screenpos(line('$'), 22))
131+
132+
1split
133+
normal G$
134+
redraw
135+
call assert_equal({'row': winrow + 0,
136+
\ 'col': wincol + 20 - 1,
137+
\ 'curscol': wincol + 20 - 1,
138+
\ 'endcol': wincol + 20 - 1},
139+
\ screenpos(win_getid(), line('.'), col('.')))
140+
141+
" w_skipcol should be subtracted
142+
setlocal nowrap
143+
normal 050zl$
144+
call assert_equal({'row': winrow + 0,
145+
\ 'col': wincol + 10 - 1,
146+
\ 'curscol': wincol + 10 - 1,
147+
\ 'endcol': wincol + 10 - 1},
148+
\ screenpos(win_getid(), line('.'), col('.')))
149+
150+
" w_skipcol should only matter for the topline
151+
" FIXME: This fails because pline_m_win() does not take w_skipcol into
152+
" account. If it does, then other tests fail.
153+
" wincmd +
154+
" setlocal wrap smoothscroll
155+
" call setline(line('$') + 1, 'last line')
156+
" exe "normal \<C-E>G$"
157+
" redraw
158+
" call assert_equal({'row': winrow + 1,
159+
" \ 'col': wincol + 9 - 1,
160+
" \ 'curscol': wincol + 9 - 1,
161+
" \ 'endcol': wincol + 9 - 1},
162+
" \ screenpos(win_getid(), line('.'), col('.')))
163+
close
131164

132165
close
133166
call assert_equal({}, screenpos(999, 1, 1))

src/version.c

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

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1600,
698700
/**/
699701
1599,
700702
/**/

0 commit comments

Comments
 (0)