vim-patch:9.1.0631: wrong completion list displayed with non-existing dir + fuzzy completion

Problem:  wrong completion list displayed with non-existing dir + fuzzy
          completion (kawarimidoll)
Solution: clear list of matches, if leader did not use fuzzy match
          (glepnir)

fixes: vim/vim#15357
closes: vim/vim#15365

6b6280c4a2

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq
2024-08-30 16:34:01 +08:00
parent a9aedfbc58
commit 9757b11aaf
3 changed files with 19 additions and 1 deletions

View File

@@ -3339,6 +3339,7 @@ static void get_next_filename_completion(void)
// Move leader to the file part // Move leader to the file part
leader = last_sep + 1; leader = last_sep + 1;
leader_len -= path_len;
} }
} }
@@ -3392,14 +3393,19 @@ static void get_next_filename_completion(void)
FreeWild(num_matches, matches); FreeWild(num_matches, matches);
matches = sorted_matches; matches = sorted_matches;
num_matches = fuzzy_indices.ga_len; num_matches = fuzzy_indices.ga_len;
} else if (leader_len > 0) {
FreeWild(num_matches, matches);
num_matches = 0;
} }
xfree(compl_fuzzy_scores); xfree(compl_fuzzy_scores);
ga_clear(&fuzzy_indices); ga_clear(&fuzzy_indices);
} }
if (num_matches > 0) {
ins_compl_add_matches(num_matches, matches, p_fic || p_wic); ins_compl_add_matches(num_matches, matches, p_fic || p_wic);
} }
}
/// Get the next set of command-line completions matching "compl_pattern". /// Get the next set of command-line completions matching "compl_pattern".
static void get_next_cmdline_completion(void) static void get_next_cmdline_completion(void)

View File

@@ -6955,6 +6955,13 @@ describe('builtin popupmenu', function()
{2:-- }{5:match 2 of 3} | {2:-- }{5:match 2 of 3} |
]]) ]])
feed('<Esc>S/non_exit_folder<C-X><C-F>')
screen:expect([[
/non_exit_folder^ |
{1:~ }|*18
{2:-- }{6:Pattern not found} |
]])
feed('<C-E><Esc>') feed('<C-E><Esc>')
end) end)

View File

@@ -1513,6 +1513,11 @@ func Test_pum_highlights_match()
call TermWait(buf, 50) call TermWait(buf, 50)
call VerifyScreenDump(buf, 'Test_pum_highlights_11', {}) call VerifyScreenDump(buf, 'Test_pum_highlights_11', {})
" issue #15357
call term_sendkeys(buf, "\<ESC>S/non_exit_folder\<C-X>\<C-F>")
call TermWait(buf, 50)
call VerifyScreenDump(buf, 'Test_pum_highlights_15', {})
call term_sendkeys(buf, "\<C-E>\<Esc>") call term_sendkeys(buf, "\<C-E>\<Esc>")
call TermWait(buf) call TermWait(buf)