changeset 28530:80085afc2f4d v8.2.4789

patch 8.2.4789: cursor pos wrong when using :redraw while editing the cmdline Commit: https://github.com/vim/vim/commit/a653e53b1f4ba08de0dbcea06288cf0cc1c6e752 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Apr 19 11:38:24 2022 +0100 patch 8.2.4789: cursor pos wrong when using :redraw while editing the cmdline 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)
author Bram Moolenaar <Bram@vim.org>
date Tue, 19 Apr 2022 12:45:03 +0200
parents 5f29eb9fcbc8
children 2a7e274ecf39
files src/ex_docmd.c src/testdir/dumps/Test_redraw_in_autocmd_1.dump src/testdir/dumps/Test_redraw_in_autocmd_2.dump src/testdir/test_cmdline.vim src/version.c
diffstat 5 files changed, 44 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -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();
 }
 
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_redraw_in_autocmd_1.dump
@@ -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
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_redraw_in_autocmd_2.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&| @1|l|e|t| |i| |=> @64
+@75
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -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(':'))
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4789,
+/**/
     4788,
 /**/
     4787,