]> granicus.if.org Git - vim/commitdiff
patch 8.1.2303: cursor in wrong position after horizontal scroll v8.1.2303
authorBram Moolenaar <Bram@vim.org>
Sat, 16 Nov 2019 13:19:33 +0000 (14:19 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 16 Nov 2019 13:19:33 +0000 (14:19 +0100)
Problem:    Cursor in wrong position after horizontal scroll.
Solution:   Set w_valid_leftcol.  (closes #5214, closes #5224)

src/move.c
src/testdir/test_matchadd_conceal.vim
src/version.c

index d340f0223cac9a4dfc490dbe00ad3eaf0bc435ca..b010ef936938e0ec84eeaee06dbd20e8cca9fc33 100644 (file)
@@ -1175,6 +1175,9 @@ curs_columns(
        redraw_later(SOME_VALID);
 #endif
 
+    // 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;
 }
 
index 83eadce5a5a91c61f36ae3b01419ca0a24cf4f8d..25bff3deadfb93a60a6111f9727a37660997bfb2 100644 (file)
@@ -316,3 +316,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
index 500ec911fcfb0fc811c50481d9342e98b25a61bd..5d97575c4f80aeccc4f2af0c9083a8d115b1250c 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2303,
 /**/
     2302,
 /**/