summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/command.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/common/command.c b/common/command.c
index 2433a89e0a..435824356b 100644
--- a/common/command.c
+++ b/common/command.c
@@ -362,13 +362,21 @@ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp)
sep = NULL;
seplen = 0;
if (i == 1) { /* one match; perfect */
- k = strlen(argv[argc - 1]);
+ if (last_char != '\0' && !isblank(last_char))
+ k = strlen(argv[argc - 1]);
+ else
+ k = 0;
+
s = cmdv[0] + k;
len = strlen(s);
sep = " ";
seplen = 1;
} else if (i > 1 && (j = find_common_prefix(cmdv)) != 0) { /* more */
- k = strlen(argv[argc - 1]);
+ if (last_char != '\0' && !isblank(last_char))
+ k = strlen(argv[argc - 1]);
+ else
+ k = 0;
+
j -= k;
if (j > 0) {
s = cmdv[0] + k;