From: Hirohito Higashi Date: Sat, 1 Aug 2026 13:32:48 +0000 (+0000) Subject: patch 9.2.0892: highlight: wrong column highlighted with 'cursorcolumn' X-Git-Tag: v9.2.0892^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a90b9dbd2e1915b7aea98813316c7279e5dd27f;p=thirdparty%2Fvim.git 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) Signed-off-by: Hirohito Higashi Signed-off-by: Christian Brabandt --- diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 38b6ae4545..2698ad6ff6 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 a5b3124212..f5271e7c17 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 0000000000..552b8cf5f5 --- /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 081eff43c5..3824ecff79 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, "\") + 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 c48aca0ff4..fe82bcdc4a 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, /**/