]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1836: 'culopt' "screenline" not redrawn with line("w0") and :retab v9.1.1836
authorzeertzjq <zeertzjq@outlook.com>
Tue, 7 Oct 2025 20:53:48 +0000 (20:53 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 7 Oct 2025 20:53:48 +0000 (20:53 +0000)
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 <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/misc2.c
src/move.c
src/proto/move.pro
src/testdir/dumps/Test_cursorline_screenline_3.dump [new file with mode: 0644]
src/testdir/test_cursorline.vim
src/version.c
src/window.c

index 368b99b88d08f97235551cc4af12058d926850fd..e88295bb6d7d5d2e752ec45c7796349402a64841 100644 (file)
@@ -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;
 }
 
index e6e78c07275dfb66d1bfce2a8cb2349ba22cab80..a40c02adf68449f42124fc99dbd4eace9be3a89a 100644 (file)
@@ -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".
index 61bc64de62fd4c1757718cc2a80f73f475cc5e01..4760ebc797c0a856ce77cf5bd4d0d1a082c228cc 100644 (file)
@@ -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 (file)
index 0000000..80a8c20
--- /dev/null
@@ -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| 
index 01a94baae7913e27f50fa4a5bcbefdd28919b9e8..1aa04c3cb300509546932335344b8c2845660235 100644 (file)
@@ -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 <F2> <Cmd>call cursor(1, 1)<CR>
+      inoremap <F3> <Cmd>call TestRetab()<CR>
   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, "\<F2>")
   call VerifyScreenDump(buf, 'Test_cursorline_screenline_2', {})
+  call term_sendkeys(buf, "\<F3>")
+  call VerifyScreenDump(buf, 'Test_cursorline_screenline_3', {})
   call term_sendkeys(buf, "\<Esc>")
 
   call StopVimInTerminal(buf)
index 987c00fa83ba3b90bb5753b52f5a26c158d1443f..c716d7f1f8a886af4931329e8304746142beb6ba 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1836,
 /**/
     1835,
 /**/
index 364b532b15ccd1f5331770d3d7d659124de81d74..e2a1eae29ea6ccf0e4343908543fc78776929536 100644 (file)
@@ -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)