Commit: patch 9.2.0873: :redrawstatus does not update the ruler of the last window

Christian Brabandt <[email protected]> Wed, 29 Jul 2026 21:00:04 +0200
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
patch 9.2.0873: :redrawstatus does not update the ruler of the last window

Commit: https://github.com/vim/vim/commit/430ea723347acdf5caa236993022ee2087f40187
Author: Hirohito Higashi <[email protected]>
Date:   Wed Jul 29 18:45:28 2026 +0000

    patch 9.2.0873: :redrawstatus does not update the ruler of the last window
    
    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) <[email protected]>
    Signed-off-by: Hirohito Higashi <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index 4a4bd6955..0a5ff259c 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -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.
 
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 2c932d4ba..a5b312421 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -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();
 }
 
 /*
diff --git a/src/testdir/dumps/Test_terminal_focus_1.dump b/src/testdir/dumps/Test_terminal_focus_1.dump
index caf67e71a..94097b92c 100644
--- a/src/testdir/dumps/Test_terminal_focus_1.dump
+++ b/src/testdir/dumps/Test_terminal_focus_1.dump
@@ -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| 
diff --git a/src/testdir/dumps/Test_terminal_focus_2.dump b/src/testdir/dumps/Test_terminal_focus_2.dump
index d02c1515f..195dbad89 100644
--- a/src/testdir/dumps/Test_terminal_focus_2.dump
+++ b/src/testdir/dumps/Test_terminal_focus_2.dump
@@ -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| 
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index ef036d2b0..a83dcb973 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -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>
 
diff --git a/src/version.c b/src/version.c
index c7eac10f8..1f78ca0d8 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 */
+/**/
+    873,
 /**/
     872,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wp9Vc-002tfR-Ex%40256bit.org.