]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0468: popups: not correctly updated from a CmdlineChanged autocommand v9.2.0468
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Sun, 10 May 2026 18:20:01 +0000 (18:20 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 10 May 2026 18:20:01 +0000 (18:20 +0000)
Problem:  popup_show() from a CmdlineChanged autocommand doesn't update
          the screen (Mao-Yining)
Solution: Refresh the screen when popups need redraw
          (Yasuhiro Matsumoto).

popup_settext()/popup_show() called from a CmdlineChanged autocommand
did not refresh the screen because cmdline mode normally skips
update_screen(), so async info-popup updates only became visible after
a manual :redraw.  Refresh the screen when popups need redrawing right
after the autocommand.

fixes:  #20175
closes: #20179

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_getln.c
src/testdir/dumps/Test_wildmenu_pum_info_async_update.dump [new file with mode: 0644]
src/testdir/test_cmdline.vim
src/version.c

index e5a9ce776f1f43aa4aa8d7751b9bb6e5d75f0cfb..7e26d6cdb4f45600bd4d376c4253a91305836bc5 100644 (file)
@@ -2696,7 +2696,17 @@ cmdline_changed:
                && (ccline.cmdpos != prev_cmdpos
                    || (prev_cmdbuff != NULL &&
                        STRCMP(prev_cmdbuff, ccline.cmdbuff) != 0)))
+       {
            trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);
+#ifdef FEAT_PROP_POPUP
+           // Show popup updates from the autocmd without a manual :redraw.
+           if (popup_need_redraw())
+           {
+               update_screen(0);
+               redrawcmd();
+           }
+#endif
+       }
 
        // Trigger CursorMovedC autocommands.
        if (ccline.cmdpos != prev_cmdpos)
diff --git a/src/testdir/dumps/Test_wildmenu_pum_info_async_update.dump b/src/testdir/dumps/Test_wildmenu_pum_info_async_update.dump
new file mode 100644 (file)
index 0000000..249f509
--- /dev/null
@@ -0,0 +1,14 @@
+| +0&#ffffff0@49
+|~+0#4040ff13&| @48
+|~| @48
+|~| @48
+|~| @48
+|~| @48
+|~| @48
+|~| @48
+|~| @48
+|~| @48
+|~| @19|╔+0#0000001#e0e0e08|═@5|X| +0#4040ff13#ffffff0@20
+|~| @3| +0#0000001#e0e0e08|1| @13|║| |d|o|n|e| |║| +0#4040ff13#ffffff0@20
+|~| @3| +0#0000001#ffd7ff255|2| @13|╚+0&#e0e0e08|═@5|⇲| +0#4040ff13#ffffff0@20
+|:+0#0000000&|T|e|s|t| |1> @42
index c10cff90bd1e3235469cd2f86e8df5f6051a8707..7c1365b6a9d18a4b743717d02489e1bc8e4bbffb 100644 (file)
@@ -3190,6 +3190,48 @@ func Test_wildmenu_pum()
   call StopVimInTerminal(buf)
 endfunc
 
+" Test that popup_settext() from a CmdlineChanged autocmd updates the
+" cmdline-mode info popup without needing an explicit :redraw (#20175).
+func Test_wildmenu_pum_info_async_update()
+  CheckScreendump
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      vim9script
+      set completeopt=menuone,popup
+      set wildmenu wildoptions=pum wildcharm=<Tab>
+      augroup Test
+          au!
+          au CmdlineChanged : UpdateInfo()
+      augroup END
+
+      def UpdateInfo()
+          if getcmdcompltype() != 'customlist,Complete'
+              return
+          endif
+          var id = popup_findinfo()
+          if id != 0
+              id->popup_settext('done')
+              popup_show(id)
+          endif
+      enddef
+
+      def Complete(_, _, _): list<dict<any>>
+          return [{word: '1', info: 'lazy'}, {word: '2', info: 'lazy'}]
+      enddef
+
+      command! -nargs=1 -complete=customlist,Complete Test echo <args>
+  END
+  call writefile(lines, 'XtestWildmenuInfoAsync', 'D')
+  let buf = RunVimInTerminal('-S XtestWildmenuInfoAsync', #{rows: 14, cols: 50})
+  call term_sendkeys(buf, ":Test \<Tab>")
+  call TermWait(buf, 200)
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_info_async_update', {})
+
+  call term_sendkeys(buf, "\<Esc>")
+  call StopVimInTerminal(buf)
+endfunc
+
 " Test for wildmenumode() with the cmdline popup menu
 func Test_wildmenumode_with_pum()
   set wildmenu
index a5ba4c7960a5e406bdcd3bb7dbde0966528679bc..f1e40ddb201677ed113e01ac99ae151f32695bd4 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    468,
 /**/
     467,
 /**/