Commit: patch 9.2.0892: highlight: wrong column highlighted with 'cursorcolumn'

0 views
Skip to first unread message

Christian Brabandt

unread,
9:45 AM (11 hours ago) 9:45 AM
to vim...@googlegroups.com
patch 9.2.0892: highlight: wrong column highlighted with 'cursorcolumn'

Commit: https://github.com/vim/vim/commit/5a90b9dbd2e1915b7aea98813316c7279e5dd27f
Author: Hirohito Higashi <h.eas...@gmail.com>
Date: Sat Aug 1 13:32:48 2026 +0000

patch 9.2.0892: highlight: wrong column highlighted with 'cursorcolumn'

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) <nor...@anthropic.com>
Signed-off-by: Hirohito Higashi <h.eas...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 38b6ae454..2698ad6ff 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -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
diff --git a/src/drawscreen.c b/src/drawscreen.c
index a5b312421..f5271e7c1 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -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
index 000000000..552b8cf5f
--- /dev/null
+++ b/src/testdir/dumps/Test_cursorcolumn_virtualedit_1.dump
@@ -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|
diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim
index 081eff43c..3824ecff7 100644
--- a/src/testdir/test_highlight.vim
+++ b/src/testdir/test_highlight.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index c48aca0ff..fe82bcdc4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 892,
/**/
891,
/**/
Reply all
Reply to author
Forward
0 new messages