]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0873: :redrawstatus does not update the ruler of the last window v9.2.0873
authorHirohito Higashi <h.east.727@gmail.com>
Wed, 29 Jul 2026 18:45:28 +0000 (18:45 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 29 Jul 2026 18:45:28 +0000 (18:45 +0000)
Problem:  When the last window has no status line the ruler takes its
          place in the last screen line, but ":redrawstatus" and
          re-setting 'rulerformat' or 'statusline' do not update it
          there.  An item such as a clock in 'rulerformat' can therefore
          not be refreshed from a timer (watael)
Solution: Also mark the ruler for redrawing when the last window has no
          status line and 'ruler' is set.  Update the documentation,
          tests and add a new test (Hirohito Higashi)

Reported: https://groups.google.com/g/vim_use/c/VKCL2bH8xlk
closes: #20865

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/various.txt
src/drawscreen.c
src/testdir/dumps/Test_terminal_focus_1.dump
src/testdir/dumps/Test_terminal_focus_2.dump
src/testdir/test_cmdline.vim
src/version.c

index 4a4bd69554149f17e0ea80b3e9e96436155d07b2..0a5ff259ca6289edbce3f52f001519d078a00522 100644 (file)
@@ -1,4 +1,4 @@
-*various.txt*  For Vim version 9.2.  Last change: 2026 Jun 13
+*various.txt*  For Vim version 9.2.  Last change: 2026 Jul 29
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -28,6 +28,9 @@ CTRL-L                        Clear and redraw the screen.  The redraw may happen
                        Useful to update the status line(s) when 'statusline'
                        includes an item that doesn't cause automatic
                        updating.
+                       When the last window has no status line the ruler is
+                       redrawn instead, this is useful when 'rulerformat'
+                       includes such an item.
                        If the command line is being edited the redraw is
                        postponed until later.
 
index 2c932d4ba749d25e925f14dae3628251a034cebf..a5b312421289eb49d502d6f73c05eb9f6b511f89 100644 (file)
@@ -3477,6 +3477,17 @@ redraw_buf_and_status_later(buf_T *buf, int type)
 }
 #endif
 
+/*
+ * mark the ruler for redraw when the last window has no status line and the
+ * ruler takes its place in the last screen line; showmode() draws it
+ */
+    static void
+ruler_redraw_lastwin(void)
+{
+    if (p_ru && lastwin->w_status_height == 0)
+       redraw_cmdline = TRUE;
+}
+
 /*
  * mark all status lines for redraw; used after first :cd
  */
@@ -3491,6 +3502,7 @@ status_redraw_all(void)
            wp->w_redr_status = true;
            redraw_later(UPD_VALID);
        }
+    ruler_redraw_lastwin();
 }
 
 /*
@@ -3507,6 +3519,8 @@ status_redraw_curbuf(void)
            wp->w_redr_status = true;
            redraw_later(UPD_VALID);
        }
+    if (lastwin->w_buffer == curbuf)
+       ruler_redraw_lastwin();
 }
 
 /*
index caf67e71afb2f1a48550e3d397903e505cb881ff..94097b92c4295d117315b92ce15f80bafc6b723b 100644 (file)
@@ -3,4 +3,4 @@
 |~| @73
 |~| @73
 |~| @73
-| +0#0000000&@56|0|,|0|-|1| @8|A|l@1| 
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
index d02c1515f36f9872f55dc46417192e2bdb5e6853..195dbad8981ab8cf63390c0e6d7b2f026f276ed1 100644 (file)
@@ -3,4 +3,4 @@
 |~| @73
 |~| @73
 |~| @73
-| +0#0000000&@56|0|,|0|-|1| @8|A|l@1| 
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
index ef036d2b0376c221641b0976f989533cf176f67d..a83dcb973c002bf3a88a65088e68cdb6b63d04bf 100644 (file)
@@ -4693,6 +4693,32 @@ func Test_rulerformat_function()
   call StopVimInTerminal(buf)
 endfunc
 
+func s:BumpRulerCounter(timer)
+  let g:ruler_counter = 2
+  redrawstatus
+endfunc
+
+" When the last window has no status line the ruler is drawn in the last
+" screen line.  ":redrawstatus" must update it there as well.
+func Test_rulerformat_redrawstatus()
+  CheckFeature timers
+
+  let save_ruf = &rulerformat
+  set ruler laststatus=0
+  let g:ruler_counter = 1
+  set rulerformat=%20(count:\ %{g:ruler_counter}%)
+  redraw!
+  call assert_match('count: 1', Screenline(&lines))
+
+  " The ruler must be updated without any key being typed.
+  call timer_start(10, function('s:BumpRulerCounter'))
+  call WaitForAssert({-> assert_match('count: 2', Screenline(&lines))})
+
+  let &rulerformat = save_ruf
+  unlet g:ruler_counter
+  set ruler& laststatus&
+endfunc
+
 func Test_getcompletion_usercmd()
   command! -nargs=* -complete=command TestCompletion echo <q-args>
 
index c7eac10f8f40f2052fbf82b26ab2b6af569a4ede..1f78ca0d8517cfb507b16634aaf3da4589d2294a 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    873,
 /**/
     872,
 /**/