mirror of
https://github.com/vim/vim.git
synced 2025-11-16 23:24:03 -05:00
patch 9.1.0605: internal error with fuzzy completion
Problem: internal error with fuzzy completion
(techntools)
Solution: only fuzzy complete the pattern after directory separator
(glepnir)
fixes: #15287
closes: #15291
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
b14c325a5b
commit
0be03e14b9
@@ -3537,11 +3537,41 @@ get_next_filename_completion(void)
|
||||
int in_fuzzy = ((get_cot_flags() & COT_FUZZY) != 0 && leader_len > 0);
|
||||
char_u **sorted_matches;
|
||||
int *fuzzy_indices_data;
|
||||
char_u *last_sep = NULL;
|
||||
size_t path_with_wildcard_len;
|
||||
char_u *path_with_wildcard;
|
||||
|
||||
if (in_fuzzy)
|
||||
{
|
||||
vim_free(compl_pattern);
|
||||
compl_pattern = vim_strsave((char_u *)"*");
|
||||
last_sep = vim_strrchr(leader, PATHSEP);
|
||||
if (last_sep == NULL)
|
||||
{
|
||||
// No path separator or separator is the last character,
|
||||
// fuzzy match the whole leader
|
||||
vim_free(compl_pattern);
|
||||
compl_pattern = vim_strsave((char_u *)"*");
|
||||
compl_patternlen = STRLEN(compl_pattern);
|
||||
}
|
||||
else if (*(last_sep + 1) == '\0')
|
||||
in_fuzzy = FALSE;
|
||||
else
|
||||
{
|
||||
// Split leader into path and file parts
|
||||
int path_len = last_sep - leader + 1;
|
||||
path_with_wildcard_len = path_len + 2;
|
||||
path_with_wildcard = alloc(path_with_wildcard_len);
|
||||
if (path_with_wildcard != NULL)
|
||||
{
|
||||
vim_strncpy(path_with_wildcard, leader, path_len);
|
||||
vim_strcat(path_with_wildcard, (char_u *)"*", path_with_wildcard_len);
|
||||
vim_free(compl_pattern);
|
||||
compl_pattern = path_with_wildcard;
|
||||
compl_patternlen = STRLEN(compl_pattern);
|
||||
|
||||
// Move leader to the file part
|
||||
leader = last_sep + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (expand_wildcards(1, &compl_pattern, &num_matches, &matches,
|
||||
|
||||
Reference in New Issue
Block a user