vim-patch:8.2.4483: command completion makes two rounds to collect matches (#21857)

Problem:    Command completion makes two rounds to collect matches.
Solution:   Use a growarray to collect matches. (Yegappan Lakshmanan,
            closes vim/vim#9860)

5de4c4372d

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq
2023-01-17 19:52:02 +08:00
committed by GitHub
parent ddd69a6c81
commit 132f001ce8
5 changed files with 194 additions and 189 deletions

View File

@@ -2415,31 +2415,34 @@ int ExpandBufnames(char *pat, int *num_file, char ***file, int options)
}
}
if (p != NULL) {
if (round == 1) {
if (p == NULL) {
continue;
}
if (round == 1) {
count++;
continue;
}
if (options & WILD_HOME_REPLACE) {
p = home_replace_save(buf, p);
} else {
p = xstrdup(p);
}
if (!fuzzy) {
if (matches != NULL) {
matches[count].buf = buf;
matches[count].match = p;
count++;
} else {
if (options & WILD_HOME_REPLACE) {
p = home_replace_save(buf, p);
} else {
p = xstrdup(p);
}
if (!fuzzy) {
if (matches != NULL) {
matches[count].buf = buf;
matches[count].match = p;
count++;
} else {
(*file)[count++] = p;
}
} else {
fuzmatch[count].idx = count;
fuzmatch[count].str = p;
fuzmatch[count].score = score;
count++;
}
(*file)[count++] = p;
}
} else {
fuzmatch[count].idx = count;
fuzmatch[count].str = p;
fuzmatch[count].score = score;
count++;
}
}
if (count == 0) { // no match found, break here