]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0892: highlight: wrong column highlighted with 'cursorcolumn' v9.2.0892
authorHirohito Higashi <h.east.727@gmail.com>
Sat, 1 Aug 2026 13:32:48 +0000 (13:32 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 1 Aug 2026 13:34:00 +0000 (13:34 +0000)
Problem:  With 'virtualedit' set to "all" and 'cursorcolumn' set, the wrong
          column may be highlighted after a command that moved the cursor
          into virtual space and back (van-de-bugger).
Solution: Make sure the virtual column is up to date before drawing the
          window (Hirohito Higashi).

fixes:  #2576
closes: #20902

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/todo.txt
src/drawscreen.c
src/testdir/dumps/Test_cursorcolumn_virtualedit_1.dump [new file with mode: 0644]
src/testdir/test_highlight.vim
src/version.c

index 38b6ae45455a9600e76928fdb722eb27bea2e274..2698ad6ff6b9c8af56a328c9df361af87a9cdde5 100644 (file)
@@ -1,4 +1,4 @@
-*todo.txt*     For Vim version 9.2.  Last change: 2026 Jul 31
+*todo.txt*     For Vim version 9.2.  Last change: 2026 Aug 01
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -57,9 +57,6 @@ Virtual text problems:
    #12232)
 -  truncated Virtual text below an empty line causes display error #12493
 
-When 'virtualedit' is "all" and 'cursorcolumn' is set, the wrong column may be
-highlighted. (van-de-bugger, 2018 Jan 23, #2576)
-
 Errors when running tests with valgrind:
 - test_codestyle.vim:  e.g.:
     command line..script /home/mool/vim/vim91/src/testdir/runtest.vim[569]..function RunTheTest[52]..Test_test_files line 6: keycode_check.vim: space before tab: Expected 0 but got 7
index a5b312421289eb49d502d6f73c05eb9f6b511f89..f5271e7c17fdc83336361f0ebc24e7612ebfcdf4 100644 (file)
@@ -1660,6 +1660,13 @@ win_update(win_T *wp)
     }
 #endif
 
+#ifdef FEAT_SYN_HL
+    // 'cursorcolumn' is drawn with w_virtcol, make sure it is up to date.
+    // This may set w_redr_type, thus do it before using it below.
+    if (wp->w_p_cuc)
+       validate_virtcol_win(wp);
+#endif
+
     type = wp->w_redr_type;
 
     if (type == UPD_NOT_VALID)
diff --git a/src/testdir/dumps/Test_cursorcolumn_virtualedit_1.dump b/src/testdir/dumps/Test_cursorcolumn_virtualedit_1.dump
new file mode 100644 (file)
index 0000000..552b8cf
--- /dev/null
@@ -0,0 +1,8 @@
+| +0&#e0e0e08| +0&#ffffff0@73
+| +0&#e0e0e08| +0&#ffffff0@73
+> @74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|3|,|0|-|1| @8|A|l@1| 
index 081eff43c5960799aa5597bd1d5b72019efd9aaf..3824ecff79bf27e37880142d90a8fd85b2b0052c 100644 (file)
@@ -622,6 +622,30 @@ func Test_cursorcolumn_insert_on_tab()
   call StopVimInTerminal(buf)
 endfunc
 
+" The column highlighted with 'cursorcolumn' must be the column of the cursor,
+" also after a command that moved the cursor into virtual space and back.
+func Test_cursorcolumn_virtualedit()
+  CheckScreendump
+
+  let lines =<< trim END
+    set virtualedit=all
+    set cursorcolumn
+    call setline(1, ['', '', ''])
+    call cursor(3, 1)
+  END
+  call writefile(lines, 'Xcuc_virtualedit', 'D')
+
+  let buf = RunVimInTerminal('-S Xcuc_virtualedit', #{rows: 8})
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_cursorcolumn_virtualedit_1', {})
+
+  call term_sendkeys(buf, "\<Del>")
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_cursorcolumn_virtualedit_1', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_cursorcolumn_callback()
   CheckScreendump
   CheckFeature timers
index c48aca0ff458e5c2de1fbd87d4b3514ce5befb75..fe82bcdc4accf8c637dacd2233cab916c3b32c1c 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    892,
 /**/
     891,
 /**/