Skip to content

Commit 08f2363

Browse files
committed
patch 8.1.2303: cursor in wrong position after horizontal scroll
Problem: Cursor in wrong position after horizontal scroll. Solution: Set w_valid_leftcol. (closes #5214, closes #5224)
1 parent f4a1d1c commit 08f2363

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/move.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,9 @@ curs_columns(
11751175
redraw_later(SOME_VALID);
11761176
#endif
11771177

1178+
// now w_leftcol is valid, avoid check_cursor_moved() thinking otherwise
1179+
curwin->w_valid_leftcol = curwin->w_leftcol;
1180+
11781181
curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;
11791182
}
11801183

src/testdir/test_matchadd_conceal.vim

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,31 @@ func Test_cursor_column_in_concealed_line_after_window_scroll()
316316
call StopVimInTerminal(buf)
317317
call delete('Xcolesearch')
318318
endfunc
319+
320+
func Test_cursor_column_in_concealed_line_after_leftcol_change()
321+
CheckRunVimInTerminal
322+
323+
" Test for issue #5214 fix.
324+
let lines =<< trim END
325+
0put = 'ab' .. repeat('-', &columns) .. 'c'
326+
call matchadd('Conceal', '-')
327+
set nowrap ss=0 cole=3 cocu=n
328+
END
329+
call writefile(lines, 'Xcurs-columns')
330+
let buf = RunVimInTerminal('-S Xcurs-columns', {})
331+
332+
" Go to the end of the line (3 columns beyond the end of the screen).
333+
" Horizontal scroll would center the cursor in the screen line, but conceal
334+
" makes it go to screen column 1.
335+
call term_sendkeys(buf, "$")
336+
call term_wait(buf)
337+
338+
" Are the concealed parts of the current line really hidden?
339+
call assert_equal('c', term_getline(buf, '.'))
340+
341+
" BugFix check: Is the window's cursor column properly updated for conceal?
342+
call assert_equal(1, term_getcursor(buf)[1])
343+
344+
call StopVimInTerminal(buf)
345+
call delete('Xcurs-columns')
346+
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+
2303,
744746
/**/
745747
2302,
746748
/**/

0 commit comments

Comments
 (0)