patch 9.1.1740: Memory leak with wildmode=longest,full and wildoptions=pum
Commit:
https://github.com/vim/vim/commit/c7f235bd432c0a7500ae39acdad7d63a614a1b33
Author: zeertzjq <
zeer...@outlook.com>
Date: Sun Sep 7 17:17:39 2025 +0200
patch 9.1.1740: Memory leak with wildmode=longest,full and wildoptions=pum
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 <
zeer...@outlook.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 1c13db901..f917dccf2 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -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
index 000000000..b3438fd0f
--- /dev/null
+++ b/src/testdir/dumps/Test_wildmenu_pum_65.dump
@@ -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
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index abbd0d2c8..fcf8fea4c 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 8e6494a5b..88906bd89 100644
--- a/src/version.c
+++ b/src/version.c
@@ -724,6 +724,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1740,
/**/
1739,
/**/