Skip to content

Commit c7f235b

Browse files
zeertzjqchrisbra
authored andcommitted
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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 1ed2ff7 commit c7f235b

4 files changed

Lines changed: 33 additions & 5 deletions

File tree

src/ex_getln.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,12 +1032,11 @@ cmdline_wildchar_complete(
10321032
if (wim_list_next || (p_wmnu && (wim_full_next
10331033
|| wim_noselect_next)))
10341034
{
1035-
if (wim_noselect_next)
1036-
options |= WILD_NOSELECT;
1037-
if (wim_full_next || wim_noselect_next)
1035+
if (wim_full_next && !wim_noselect_next)
10381036
nextwild(xp, WILD_NEXT, options, escape);
1039-
(void)showmatches(xp, p_wmnu, wim_list_next,
1040-
wim_noselect_next);
1037+
else
1038+
(void)showmatches(xp, p_wmnu, wim_list_next,
1039+
wim_noselect_next);
10411040
if (wim_list_next)
10421041
*did_wild_list = TRUE;
10431042
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
| +0&#ffffff0@74
2+
|~+0#4040ff13&| @73
3+
|~| @73
4+
|~| @73
5+
|~| @73
6+
|~| @73
7+
|~| @73
8+
|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
9+
|~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
10+
|:+0#0000000&|s|i|g|n| |u|n> @66

src/testdir/test_cmdline.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,6 +2973,23 @@ func Test_wildmenu_pum()
29732973
call term_sendkeys(buf, ":cn\<Tab>")
29742974
call VerifyScreenDump(buf, 'Test_wildmenu_pum_64', {})
29752975

2976+
" If "longest" finds no candidate in "longest,full", "full" is used
2977+
call term_sendkeys(buf, "\<Esc>:set wildmode=longest,full\<CR>")
2978+
call term_sendkeys(buf, ":set wildoptions=pum\<CR>")
2979+
call term_sendkeys(buf, ":sign un\<Tab>")
2980+
call VerifyScreenDump(buf, 'Test_wildmenu_pum_09', {})
2981+
call term_sendkeys(buf, "\<Tab>")
2982+
call VerifyScreenDump(buf, 'Test_wildmenu_pum_10', {})
2983+
2984+
" Similarly for "longest,noselect:full"
2985+
call term_sendkeys(buf, "\<Esc>:set wildmode=longest,noselect:full\<CR>")
2986+
call term_sendkeys(buf, ":sign un\<Tab>")
2987+
call VerifyScreenDump(buf, 'Test_wildmenu_pum_65', {})
2988+
call term_sendkeys(buf, "\<Tab>")
2989+
call VerifyScreenDump(buf, 'Test_wildmenu_pum_09', {})
2990+
call term_sendkeys(buf, "\<Tab>")
2991+
call VerifyScreenDump(buf, 'Test_wildmenu_pum_10', {})
2992+
29762993
call term_sendkeys(buf, "\<C-U>\<Esc>")
29772994
call StopVimInTerminal(buf)
29782995
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,8 @@ static char *(features[]) =
724724

725725
static int included_patches[] =
726726
{ /* Add new patch number below this line */
727+
/**/
728+
1740,
727729
/**/
728730
1739,
729731
/**/

0 commit comments

Comments
 (0)