From 2b956f84bb3ad9b8e65d09565154c97ecb74300b Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 30 Dec 2010 17:45:56 +0300 Subject: [PATCH] Ticket #2458: fixed broken command autocompletion. Signed-off-by: Andrew Borodin --- src/filemanager/complete.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/filemanager/complete.c b/src/filemanager/complete.c index 1e58ebd60..2a8691df1 100644 --- a/src/filemanager/complete.c +++ b/src/filemanager/complete.c @@ -794,6 +794,7 @@ check_is_cd (const char *text, int lc_start, input_complete_t flags) char *p, *q; SHOW_C_CTX ("check_is_cd"); + if ((flags & INPUT_COMPLETE_CD) == 0) return FALSE; @@ -812,7 +813,7 @@ check_is_cd (const char *text, int lc_start, input_complete_t flags) static char ** try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags) { - int in_command_position = 0; + size_t in_command_position = 0; char *word; char **matches = NULL; char *p = NULL, *q = NULL, *r = NULL; @@ -835,11 +836,15 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags) if (*lc_start == 0) ti = text; else + { ti = str_get_prev_char (&text[*lc_start]); - while (ti > text && (ti[0] == ' ' || ti[0] == '\t')) - str_prev_char (&ti); + while (ti > text && (ti[0] == ' ' || ti[0] == '\t')) + str_prev_char (&ti); + } - if (strchr (command_separator_chars, ti[0]) != NULL) + if (ti == text) + in_command_position++; + else if (strchr (command_separator_chars, ti[0]) != NULL) { int this_char, prev_char; @@ -915,7 +920,7 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags) /* And finally if this word is in a command position, then complete over possible command names, including aliases, functions, and command names. */ - if (!matches && in_command_position) + if (!matches && in_command_position != 0) { SHOW_C_CTX ("try_complete:cmd_subst"); matches = -- 2.11.4.GIT