changeset 24291:93b401236991 v8.2.2686

patch 8.2.2686: status line is not updated when going to cmdline mode Commit: https://github.com/vim/vim/commit/ce0b75711afb3ff260967a0843bca46ec09604b5 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 1 18:47:14 2021 +0200 patch 8.2.2686: status line is not updated when going to cmdline mode Problem: Status line is not updated when going to cmdline mode. Solution: Redraw status lines if 'statusline' is set and going to status line mode. (based on patch from Justin M. Keyes et al., closes #8044)
author Bram Moolenaar <Bram@vim.org>
date Thu, 01 Apr 2021 19:00:03 +0200
parents b776f5c2e2c2
children 09302e0fb4a5
files src/ex_getln.c src/testdir/dumps/Test_statusline_mode_1.dump src/testdir/dumps/Test_statusline_mode_2.dump src/testdir/test_statusline.vim src/version.c
diffstat 5 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1706,6 +1706,15 @@ getcmdline_int(
     // and execute commands. Display may be messed up a bit.
     if (did_emsg)
 	redrawcmd();
+
+    // Redraw the statusline in case it uses the current mode using the mode()
+    // function.
+    if (!cmd_silent && msg_scrolled == 0 && *p_stl != NUL)
+    {
+	curwin->w_redr_status = TRUE;
+	redraw_statuslines();
+    }
+
     did_emsg = FALSE;
     got_int = FALSE;
 
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_statusline_mode_1.dump
@@ -0,0 +1,5 @@
+> +0&#ffffff0@49
+|~+0#4040ff13&| @48
+|~| @48
+|-+3#0000000&|n|-| @46
+| +0&&@49
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_statusline_mode_2.dump
@@ -0,0 +1,5 @@
+| +0&#ffffff0@49
+|~+0#4040ff13&| @48
+|~| @48
+|-+3#0000000&|c|-| @46
+|:+0&&> @48
--- a/src/testdir/test_statusline.vim
+++ b/src/testdir/test_statusline.vim
@@ -448,6 +448,27 @@ func Test_statusline_removed_group()
   call delete('XTest_statusline')
 endfunc
 
+func Test_statusline_using_mode()
+  CheckScreendump
+
+  let lines =<< trim END
+    set laststatus=2
+    let &statusline = '-%{mode()}-'
+  END
+  call writefile(lines, 'XTest_statusline')
+
+  let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 5, 'cols': 50})
+  call VerifyScreenDump(buf, 'Test_statusline_mode_1', {})
+
+  call term_sendkeys(buf, ":")
+  call VerifyScreenDump(buf, 'Test_statusline_mode_2', {})
+
+  " clean up
+  call term_sendkeys(buf, "\<CR>")
+  call StopVimInTerminal(buf)
+  call delete('XTest_statusline')
+endfunc
+
 func Test_statusline_after_split_vsplit()
   only
 
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2686,
+/**/
     2685,
 /**/
     2684,