diff options
-rw-r--r-- | src/nvim/move.c | 4 | ||||
-rw-r--r-- | test/old/testdir/test_cursor_func.vim | 35 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index 48691db26d..57466120e9 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1098,6 +1098,10 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp, col += off; int width = wp->w_width_inner - 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_inner && width > 0) { // use same formula as what is used in curs_columns() diff --git a/test/old/testdir/test_cursor_func.vim b/test/old/testdir/test_cursor_func.vim index 239eff5db5..7c8b691f66 100644 --- a/test/old/testdir/test_cursor_func.vim +++ b/test/old/testdir/test_cursor_func.vim @@ -125,7 +125,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)) |