]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1740: Memory leak with wildmode=longest,full and wildoptions=pum v9.1.1740
authorzeertzjq <zeertzjq@outlook.com>
Sun, 7 Sep 2025 15:17:39 +0000 (17:17 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 7 Sep 2025 15:17:39 +0000 (17:17 +0200)
Problem:  Memory leak with wildmode=longest,full and wildoptions=pum
          (after 9.1.1737).
Solution: Avoid using showmatches() and WILD_NEXT together.  Also fix
          wildmode=longest,noselect:full selecting wrong item
          (zeertzjq).

fixes: #18228
closes: #18229

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_getln.c
src/testdir/dumps/Test_wildmenu_pum_65.dump [new file with mode: 0644]
src/testdir/test_cmdline.vim
src/version.c

index 1c13db901824f97f71ec2d553faf3af2b895e56c..f917dccf2271913e14b578e853b3df1fce35721f 100644 (file)
@@ -1032,12 +1032,11 @@ cmdline_wildchar_complete(
                    if (wim_list_next || (p_wmnu && (wim_full_next
                                    || wim_noselect_next)))
                    {
-                       if (wim_noselect_next)
-                           options |= WILD_NOSELECT;
-                       if (wim_full_next || wim_noselect_next)
+                       if (wim_full_next && !wim_noselect_next)
                            nextwild(xp, WILD_NEXT, options, escape);
-                       (void)showmatches(xp, p_wmnu, wim_list_next,
-                               wim_noselect_next);
+                       else
+                           (void)showmatches(xp, p_wmnu, wim_list_next,
+                                   wim_noselect_next);
                        if (wim_list_next)
                            *did_wild_list = TRUE;
                    }
diff --git a/src/testdir/dumps/Test_wildmenu_pum_65.dump b/src/testdir/dumps/Test_wildmenu_pum_65.dump
new file mode 100644 (file)
index 0000000..b3438fd
--- /dev/null
@@ -0,0 +1,10 @@
+| +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
+|~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
+|:+0#0000000&|s|i|g|n| |u|n> @66
index abbd0d2c866e966eb7e70021741b35cf0958c00a..fcf8fea4c6574f22d56ede6a06a624b999364c55 100644 (file)
@@ -2973,6 +2973,23 @@ func Test_wildmenu_pum()
   call term_sendkeys(buf, ":cn\<Tab>")
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_64', {})
 
+  " If "longest" finds no candidate in "longest,full", "full" is used
+  call term_sendkeys(buf, "\<Esc>:set wildmode=longest,full\<CR>")
+  call term_sendkeys(buf, ":set wildoptions=pum\<CR>")
+  call term_sendkeys(buf, ":sign un\<Tab>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_09', {})
+  call term_sendkeys(buf, "\<Tab>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_10', {})
+
+  " Similarly for "longest,noselect:full"
+  call term_sendkeys(buf, "\<Esc>:set wildmode=longest,noselect:full\<CR>")
+  call term_sendkeys(buf, ":sign un\<Tab>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_65', {})
+  call term_sendkeys(buf, "\<Tab>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_09', {})
+  call term_sendkeys(buf, "\<Tab>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_10', {})
+
   call term_sendkeys(buf, "\<C-U>\<Esc>")
   call StopVimInTerminal(buf)
 endfunc
index 8e6494a5b1be937e46ec317d308dbe2aea36bb9f..88906bd89822dea0c593eaadb2dc8c66af97a660 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1740,
 /**/
     1739,
 /**/