summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-03 17:11:47 +0100
committerBram Moolenaar <Bram@vim.org>2023-06-03 17:11:47 +0100
commitf0e68c0e2a3539f899e737e5b167622fe081fbbd (patch)
treed85ba59c7212d8d42e1e9a6c86f55da646e00dfc
parenta109f39ef54bc3894768170f02c1b6ac56164488 (diff)
patch 9.0.1600: screenpos() does not take w_skipcol into accountv9.0.1600
Problem: screenpos() does not take w_skipcol into account. Solution: Subtract w_skipcol from column. (closes #12486, closes #12476)
-rw-r--r--src/move.c3
-rw-r--r--src/testdir/test_cursor_func.vim35
-rw-r--r--src/version.c2
3 files changed, 39 insertions, 1 deletions
diff --git a/src/move.c b/src/move.c
index a1139199e6..ff2f494017 100644
--- a/src/move.c
+++ b/src/move.c
@@ -1479,6 +1479,9 @@ textpos2screenpos(
col += off;
width = wp->w_width - off + win_col_off2(wp);
+ if (pos->lnum == wp->w_topline)
+ col -= wp->w_skipcol;
+
// long line wrapping, adjust row
if (wp->w_p_wrap
&& col >= (colnr_T)wp->w_width
diff --git a/src/testdir/test_cursor_func.vim b/src/testdir/test_cursor_func.vim
index d74255e19b..c37826cbc1 100644
--- a/src/testdir/test_cursor_func.vim
+++ b/src/testdir/test_cursor_func.vim
@@ -127,7 +127,40 @@ func Test_screenpos()
\ 'curscol': wincol + 7,
\ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8))
call assert_equal({'row': 0, 'col': 0, 'curscol': 0, 'endcol': 0},
- \ winid->screenpos(line('$'), 22))
+ \ winid->screenpos(line('$'), 22))
+
+ 1split
+ normal G$
+ redraw
+ call assert_equal({'row': winrow + 0,
+ \ 'col': wincol + 20 - 1,
+ \ 'curscol': wincol + 20 - 1,
+ \ 'endcol': wincol + 20 - 1},
+ \ screenpos(win_getid(), line('.'), col('.')))
+
+ " w_skipcol should be subtracted
+ setlocal nowrap
+ normal 050zl$
+ call assert_equal({'row': winrow + 0,
+ \ 'col': wincol + 10 - 1,
+ \ 'curscol': wincol + 10 - 1,
+ \ 'endcol': wincol + 10 - 1},
+ \ screenpos(win_getid(), line('.'), col('.')))
+
+ " w_skipcol should only matter for the topline
+" FIXME: This fails because pline_m_win() does not take w_skipcol into
+" account. If it does, then other tests fail.
+" wincmd +
+" setlocal wrap smoothscroll
+" call setline(line('$') + 1, 'last line')
+" exe "normal \<C-E>G$"
+" redraw
+" call assert_equal({'row': winrow + 1,
+" \ 'col': wincol + 9 - 1,
+" \ 'curscol': wincol + 9 - 1,
+" \ 'endcol': wincol + 9 - 1},
+" \ screenpos(win_getid(), line('.'), col('.')))
+ close
close
call assert_equal({}, screenpos(999, 1, 1))
diff --git a/src/version.c b/src/version.c
index 872587e3ee..b854893fc3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1600,
+/**/
1599,
/**/
1598,