From 818e794f12171ab0fd62152e7d197da7bc43535f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 8 Oct 2020 07:51:29 -0400 Subject: vim-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 vim/vim#5214, closes vim/vim#5224) https://github.com/vim/vim/commit/08f23636aef595f4cc061dfee8248dca97df16b3 --- src/nvim/move.c | 3 +++ src/nvim/testdir/test_matchadd_conceal.vim | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/nvim/move.c b/src/nvim/move.c index 8a8a639a52..4e9d42ed7b 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -943,6 +943,9 @@ void curs_columns( redraw_later(SOME_VALID); } + // now w_leftcol is valid, avoid check_cursor_moved() thinking otherwise + curwin->w_valid_leftcol = curwin->w_leftcol; + curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL; } diff --git a/src/nvim/testdir/test_matchadd_conceal.vim b/src/nvim/testdir/test_matchadd_conceal.vim index cb70b2857f..ec9f4d5575 100644 --- a/src/nvim/testdir/test_matchadd_conceal.vim +++ b/src/nvim/testdir/test_matchadd_conceal.vim @@ -312,3 +312,31 @@ func Test_cursor_column_in_concealed_line_after_window_scroll() call StopVimInTerminal(buf) call delete('Xcolesearch') endfunc + +func Test_cursor_column_in_concealed_line_after_leftcol_change() + CheckRunVimInTerminal + + " Test for issue #5214 fix. + let lines =<< trim END + 0put = 'ab' .. repeat('-', &columns) .. 'c' + call matchadd('Conceal', '-') + set nowrap ss=0 cole=3 cocu=n + END + call writefile(lines, 'Xcurs-columns') + let buf = RunVimInTerminal('-S Xcurs-columns', {}) + + " Go to the end of the line (3 columns beyond the end of the screen). + " Horizontal scroll would center the cursor in the screen line, but conceal + " makes it go to screen column 1. + call term_sendkeys(buf, "$") + call term_wait(buf) + + " Are the concealed parts of the current line really hidden? + call assert_equal('c', term_getline(buf, '.')) + + " BugFix check: Is the window's cursor column properly updated for conceal? + call assert_equal(1, term_getcursor(buf)[1]) + + call StopVimInTerminal(buf) + call delete('Xcurs-columns') +endfunc -- cgit