aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-17 19:52:02 +0800
committerGitHub <noreply@github.com>2023-01-17 19:52:02 +0800
commit132f001ce84d8d750ac5c492a23b7d499fb47c6a (patch)
treebf5908c4909e5cf87efb47b37dcab1dbb11951fa /src/nvim/buffer.c
parentddd69a6c81c1a2595e81377503dd2b47f2c41b83 (diff)
downloadrneovim-132f001ce84d8d750ac5c492a23b7d499fb47c6a.tar.gz
rneovim-132f001ce84d8d750ac5c492a23b7d499fb47c6a.tar.bz2
rneovim-132f001ce84d8d750ac5c492a23b7d499fb47c6a.zip
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) https://github.com/vim/vim/commit/5de4c4372d4366bc85cb66efb3e373439b9471c5 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 9dd5fdaea5..3f93d85624 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -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