patch 8.2.4483: command completion makes two rounds to collect matches
Problem: Command completion makes two rounds to collect matches.
Solution: Use a growarray to collect matches. (Yegappan Lakshmanan,
closes #9860)
diff --git a/src/buffer.c b/src/buffer.c
index e580874..8e68d94 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2814,38 +2814,39 @@
}
}
- if (p != NULL)
- {
- if (round == 1)
- ++count;
- else
- {
- if (options & WILD_HOME_REPLACE)
- p = home_replace_save(buf, p);
- else
- p = vim_strsave(p);
+ if (p == NULL)
+ continue;
- if (!fuzzy)
- {
+ if (round == 1)
+ {
+ ++count;
+ continue;
+ }
+
+ if (options & WILD_HOME_REPLACE)
+ p = home_replace_save(buf, p);
+ else
+ p = vim_strsave(p);
+
+ if (!fuzzy)
+ {
#ifdef FEAT_VIMINFO
- if (matches != NULL)
- {
- matches[count].buf = buf;
- matches[count].match = p;
- count++;
- }
- else
-#endif
- (*file)[count++] = p;
- }
- else
- {
- fuzmatch[count].idx = count;
- fuzmatch[count].str = p;
- fuzmatch[count].score = score;
- count++;
- }
+ if (matches != NULL)
+ {
+ matches[count].buf = buf;
+ matches[count].match = p;
+ count++;
}
+ else
+#endif
+ (*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