From c7f235bd432c0a7500ae39acdad7d63a614a1b33 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 7 Sep 2025 17:17:39 +0200 Subject: [PATCH] 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 Signed-off-by: Christian Brabandt --- src/ex_getln.c | 9 ++++----- src/testdir/dumps/Test_wildmenu_pum_65.dump | 10 ++++++++++ src/testdir/test_cmdline.vim | 17 +++++++++++++++++ src/version.c | 2 ++ 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 src/testdir/dumps/Test_wildmenu_pum_65.dump diff --git a/src/ex_getln.c b/src/ex_getln.c index 1c13db9018..f917dccf22 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 0000000000..b3438fd0f2 --- /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 abbd0d2c86..fcf8fea4c6 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\") call VerifyScreenDump(buf, 'Test_wildmenu_pum_64', {}) + " If "longest" finds no candidate in "longest,full", "full" is used + call term_sendkeys(buf, "\:set wildmode=longest,full\") + call term_sendkeys(buf, ":set wildoptions=pum\") + call term_sendkeys(buf, ":sign un\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_09', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_10', {}) + + " Similarly for "longest,noselect:full" + call term_sendkeys(buf, "\:set wildmode=longest,noselect:full\") + call term_sendkeys(buf, ":sign un\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_65', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_09', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_10', {}) + call term_sendkeys(buf, "\\") call StopVimInTerminal(buf) endfunc diff --git a/src/version.c b/src/version.c index 8e6494a5b1..88906bd898 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, /**/