From a0849143614e687a305b6195dd8724840786e372 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 7 Oct 2025 20:53:48 +0000 Subject: [PATCH] patch 9.1.1836: 'culopt' "screenline" not redrawn with line("w0") and :retab Problem: 'cursorlineopt' "screenline" isn't redrawn when moving cursor and then using line("w0") and :retab that does nothing. Solution: Call redraw_for_cursorcolumn() when setting a valid w_virtcol (zeertzjq). closes: #18506 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- src/misc2.c | 10 ++-------- src/move.c | 14 ++++++++++++++ src/proto/move.pro | 1 + .../dumps/Test_cursorline_screenline_3.dump | 8 ++++++++ src/testdir/test_cursorline.vim | 12 +++++++++++- src/version.c | 2 ++ src/window.c | 2 +- 7 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 src/testdir/dumps/Test_cursorline_screenline_3.dump diff --git a/src/misc2.c b/src/misc2.c index 368b99b88d..e88295bb6d 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -60,11 +60,8 @@ coladvance_force(colnr_T wcol) if (wcol == MAXCOL) curwin->w_valid &= ~VALID_VIRTCOL; else - { // Virtcol is valid - curwin->w_valid |= VALID_VIRTCOL; - curwin->w_virtcol = wcol; - } + set_valid_virtcol(curwin, wcol); return rc; } @@ -101,11 +98,8 @@ coladvance(colnr_T wantcol) if (wantcol == MAXCOL || rc == FAIL) curwin->w_valid &= ~VALID_VIRTCOL; else if (*ml_get_cursor() != TAB) - { // Virtcol is valid when not on a TAB - curwin->w_valid |= VALID_VIRTCOL; - curwin->w_virtcol = wantcol; - } + set_valid_virtcol(curwin, wantcol); return rc; } diff --git a/src/move.c b/src/move.c index e6e78c0727..a40c02adf6 100644 --- a/src/move.c +++ b/src/move.c @@ -193,6 +193,20 @@ redraw_for_cursorcolumn(win_T *wp) } #endif +/* + * Set wp->w_virtcol to a value ("vcol") that is already valid. + * Handles redrawing if wp->w_virtcol was previously invalid. + */ + void +set_valid_virtcol(win_T *wp, colnr_T vcol) +{ + wp->w_virtcol = vcol; +#ifdef FEAT_SYN_HL + redraw_for_cursorcolumn(wp); +#endif + wp->w_valid |= VALID_VIRTCOL; +} + /* * Calculates how much the 'listchars' "precedes" or 'smoothscroll' "<<<" * marker overlaps with buffer text for window "wp". diff --git a/src/proto/move.pro b/src/proto/move.pro index 61bc64de62..4760ebc797 100644 --- a/src/proto/move.pro +++ b/src/proto/move.pro @@ -1,5 +1,6 @@ /* move.c */ int adjust_plines_for_skipcol(win_T *wp); +void set_valid_virtcol(win_T *wp, colnr_T vcol); int sms_marker_overlap(win_T *wp, int extra2); void update_topline_redraw(void); void update_topline(void); diff --git a/src/testdir/dumps/Test_cursorline_screenline_3.dump b/src/testdir/dumps/Test_cursorline_screenline_3.dump new file mode 100644 index 0000000000..80a8c20e6e --- /dev/null +++ b/src/testdir/dumps/Test_cursorline_screenline_3.dump @@ -0,0 +1,8 @@ +|x+0&#ffffff0|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z +> +8&&|x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| @30 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|1|,|7|6| @9|A|l@1| diff --git a/src/testdir/test_cursorline.vim b/src/testdir/test_cursorline.vim index 01a94baae7..1aa04c3cb3 100644 --- a/src/testdir/test_cursorline.vim +++ b/src/testdir/test_cursorline.vim @@ -292,9 +292,17 @@ func Test_cursorline_screenline_update() CheckScreendump let lines =<< trim END + func TestRetab() + let w = winwidth(0) + call cursor([1, w + 1, 0, w + 1]) + call line('w0') + retab 8 + endfunc + call setline(1, repeat('xyz ', 30)) - set cursorline cursorlineopt=screenline + set cursorline cursorlineopt=screenline tabstop=8 inoremap call cursor(1, 1) + inoremap call TestRetab() END call writefile(lines, 'Xcul_screenline', 'D') @@ -303,6 +311,8 @@ func Test_cursorline_screenline_update() call VerifyScreenDump(buf, 'Test_cursorline_screenline_1', {}) call term_sendkeys(buf, "\") call VerifyScreenDump(buf, 'Test_cursorline_screenline_2', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_cursorline_screenline_3', {}) call term_sendkeys(buf, "\") call StopVimInTerminal(buf) diff --git a/src/version.c b/src/version.c index 987c00fa83..c716d7f1f8 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1836, /**/ 1835, /**/ diff --git a/src/window.c b/src/window.c index 364b532b15..e2a1eae29e 100644 --- a/src/window.c +++ b/src/window.c @@ -7077,7 +7077,7 @@ set_fraction(win_T *wp) * calculate the new scroll position. * TODO: Ensure this also works with wrapped lines. * Requires a not fully visible cursor line to be allowed at the bottom of - * a window("zb"), probably only when 'smoothscroll' is also set. + * a window ("zb"), probably only when 'smoothscroll' is also set. */ static void win_fix_scroll(int resize)