]> granicus.if.org Git - vim/commitdiff
patch 9.0.0507: cmdline cleared when using :redrawstatus in CmdlineChanged v9.0.0507
authorBram Moolenaar <Bram@vim.org>
Mon, 19 Sep 2022 20:16:12 +0000 (21:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 19 Sep 2022 20:16:12 +0000 (21:16 +0100)
Problem:    Command line cleared when using :redrawstatus in CmdlineChanged
            autocommand event.
Solution:   Postpone the redraw. (closes #11162)

src/ex_docmd.c
src/testdir/dumps/Test_redrawstatus_in_autocmd_1.dump [new file with mode: 0644]
src/testdir/test_cmdline.vim
src/version.c

index 814f1b6f8a5a8818bc50d81a93b64eb3106b3857..3076d5344b422acb5d78c33def0a3ea2a1db5114 100644 (file)
@@ -8427,12 +8427,15 @@ ex_redrawstatus(exarg_T *eap UNUSED)
     int                r = RedrawingDisabled;
     int                p = p_lz;
 
-    RedrawingDisabled = 0;
-    p_lz = FALSE;
     if (eap->forceit)
        status_redraw_all();
     else
        status_redraw_curbuf();
+    if (State & MODE_CMDLINE)
+       return;  // redraw later
+
+    RedrawingDisabled = 0;
+    p_lz = FALSE;
     update_screen(VIsual_active ? UPD_INVERTED : 0);
     RedrawingDisabled = r;
     p_lz = p;
diff --git a/src/testdir/dumps/Test_redrawstatus_in_autocmd_1.dump b/src/testdir/dumps/Test_redrawstatus_in_autocmd_1.dump
new file mode 100644 (file)
index 0000000..91e4364
--- /dev/null
@@ -0,0 +1,8 @@
+|~+0#4040ff13#ffffff0| @73
+|~| @73
+|~| @73
+|o+0#0000000&|n|e| @71
+|t|w|o| @71
+|t|h|r|e@1| @69
+|f|o|u|r| @70
+|:|f|o@1|b|a|r> @67
index 27ca8bf841b5c06f03f32859978ca5a1c0215032..3014ac36a5c67411b1945c4615932d97086d5530 100644 (file)
@@ -210,6 +210,25 @@ func Test_redraw_in_autocmd()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_redrawstatus_in_autocmd()
+  CheckScreendump
+
+  let lines =<< trim END
+      set cmdheight=2
+      autocmd CmdlineChanged * if getcmdline() == 'foobar' | redrawstatus | endif
+  END
+  call writefile(lines, 'XTest_redrawstatus', 'D')
+
+  let buf = RunVimInTerminal('-S XTest_redrawstatus', {'rows': 8})
+  call term_sendkeys(buf, ":echo \"one\\ntwo\\nthree\\nfour\"\<CR>")
+  call term_sendkeys(buf, ":foobar")
+  call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_1', {})
+
+  " clean up
+  call term_sendkeys(buf, "\<CR>")
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_changing_cmdheight()
   CheckScreendump
 
index 15f5e385443a69a156039fc7ea8098406a945366..554f8f1e903e917a5590b309000dc2d9d2439c82 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    507,
 /**/
     506,
 /**/