]> granicus.if.org Git - vim/commitdiff
patch 8.2.4789: cursor pos wrong when using :redraw while editing the cmdline v8.2.4789
authorBram Moolenaar <Bram@vim.org>
Tue, 19 Apr 2022 10:38:24 +0000 (11:38 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 19 Apr 2022 10:38:24 +0000 (11:38 +0100)
Problem:    The cursor may be in the in wrong place when using :redraw while
            editing the cmdline.
Solution:   When editing the command line let :redraw update the command line
            too. (closes #10210)

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

index 58df97a9aa61503a7b4c4aa180a5bbbb7cb4f282..5c86cee45bc213fc566a23089df37e76648385fe 100644 (file)
@@ -8323,6 +8323,10 @@ ex_redraw(exarg_T *eap)
     // No need to wait after an intentional redraw.
     need_wait_return = FALSE;
 
+    // When invoked from a callback or autocmd the command line may be active.
+    if (State & CMDLINE)
+       redrawcmdline();
+
     out_flush();
 }
 
diff --git a/src/testdir/dumps/Test_redraw_in_autocmd_1.dump b/src/testdir/dumps/Test_redraw_in_autocmd_1.dump
new file mode 100644 (file)
index 0000000..8939b70
--- /dev/null
@@ -0,0 +1,8 @@
+| +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|f|o|r| |i| |i|n| |r|a|n|g|e|(|3|)| @56
+|:| @1> @71
diff --git a/src/testdir/dumps/Test_redraw_in_autocmd_2.dump b/src/testdir/dumps/Test_redraw_in_autocmd_2.dump
new file mode 100644 (file)
index 0000000..17b7e04
--- /dev/null
@@ -0,0 +1,8 @@
+| +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&| @1|l|e|t| |i| |=> @64
+@75
index 8baa1ac6f5b6d4860a2564f875276522836f999a..8d556faf0a73732cdc18d2f69ebdb40bb6ab95bb 100644 (file)
@@ -193,6 +193,28 @@ func Test_wildmenu_screendump()
   call delete('XTest_wildmenu')
 endfunc
 
+func Test_redraw_in_autocmd()
+  CheckScreendump
+
+  let lines =<< trim END
+      set cmdheight=2
+      autocmd CmdlineChanged * redraw
+  END
+  call writefile(lines, 'XTest_redraw')
+
+  let buf = RunVimInTerminal('-S XTest_redraw', {'rows': 8})
+  call term_sendkeys(buf, ":for i in range(3)\<CR>")
+  call VerifyScreenDump(buf, 'Test_redraw_in_autocmd_1', {})
+
+  call term_sendkeys(buf, "let i =")
+  call VerifyScreenDump(buf, 'Test_redraw_in_autocmd_2', {})
+
+  " clean up
+  call term_sendkeys(buf, "\<CR>")
+  call StopVimInTerminal(buf)
+  call delete('XTest_redraw')
+endfunc
+
 func Test_map_completion()
   call feedkeys(":map <unique> <si\<Tab>\<Home>\"\<CR>", 'xt')
   call assert_equal('"map <unique> <silent>', getreg(':'))
index 411ea1ad8d41d34407425be9c90ddeef640b7b94..b837fcbd730adff7ea5b11e022591a8412c9e8f6 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4789,
 /**/
     4788,
 /**/