libedit: Fix a bug that could make completion listings incomplete.
The element matches[0] is the common prefix and is not counted in len, so subtracting 1 is not needed. A counter for the number of matches per line was incremented twice. Submitted by: Guy Yur
This commit is contained in:
parent
547d94bde3
commit
da8301c83a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=209217
@ -347,13 +347,12 @@ fn_display_match_list(EditLine *el, char **matches, size_t len, size_t max)
|
|||||||
count++;
|
count++;
|
||||||
|
|
||||||
/* Sort the items if they are not already sorted. */
|
/* Sort the items if they are not already sorted. */
|
||||||
qsort(&matches[1], (size_t)(len - 1), sizeof(char *),
|
qsort(&matches[1], len, sizeof(char *), _fn_qsort_string_compare);
|
||||||
_fn_qsort_string_compare);
|
|
||||||
|
|
||||||
idx = 1;
|
idx = 1;
|
||||||
for(; count > 0; count--) {
|
for(; count > 0; count--) {
|
||||||
int more = limit > 0 && matches[0];
|
int more = limit > 0 && matches[0];
|
||||||
for(i = 0; more; i++, idx++) {
|
for(i = 0; more; idx++) {
|
||||||
more = ++i < limit && matches[idx + 1];
|
more = ++i < limit && matches[idx + 1];
|
||||||
(void)fprintf(el->el_outfile, "%-*s%s", (int)max,
|
(void)fprintf(el->el_outfile, "%-*s%s", (int)max,
|
||||||
matches[idx], more ? " " : "");
|
matches[idx], more ? " " : "");
|
||||||
|
Loading…
Reference in New Issue
Block a user