diff --git a/src/files.c b/src/files.c index c4ddf1c33686c41376988ef0fc135524f3e4fa51..08c9fd654bd983dc0101d3850978a3bddd55fb5e 100644 --- a/src/files.c +++ b/src/files.c @@ -2755,14 +2755,15 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t * position should be advanced. refresh_func is the function we will * call to refresh the edit window. */ char *input_tab(char *buf, bool allow_files, size_t *place, - bool *lastwastab, void (*refresh_func)(void)) + bool *lastwastab, void (*refresh_func)(void), bool *listed) { size_t num_matches = 0, buf_len; char **matches = NULL; - bool listed = FALSE; assert(buf != NULL && place != NULL && *place <= strlen(buf) && - lastwastab != NULL && refresh_func != NULL); + lastwastab != NULL && refresh_func != NULL && listed != NULL); + + *listed = FALSE; /* If the word starts with `~' and there is no slash in the word, * then try completing this word as a username. */ @@ -2888,8 +2889,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place, } wnoutrefresh(edit); - refresh_needed = TRUE; - listed = TRUE; + *listed = TRUE; } free(mzero); @@ -2897,8 +2897,9 @@ char *input_tab(char *buf, bool allow_files, size_t *place, free_chararray(matches, num_matches); - /* Refresh the edit window just in case a previous tab showed a list. */ - if (!listed) + /* When we didn't list any matches now, refresh the edit window, just + * in case a previous tab showed a list, so we know where we are. */ + if (!*listed) refresh_func(); return buf; diff --git a/src/prompt.c b/src/prompt.c index 53e1ad6487d73a9aa43395d1efdb8981a4af0413..eacae87adb72c5190b6dba365a2302d87c657158 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -529,7 +529,7 @@ void update_bar_if_needed(void) /* Get a string of input at the statusbar prompt. */ functionptrtype get_prompt_string(int *actual, bool allow_tabs, #ifndef DISABLE_TABCOMP - bool allow_files, + bool allow_files, bool *listed, #endif const char *curranswer, #ifndef DISABLE_HISTORIES @@ -619,7 +619,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, #endif if (allow_tabs) answer = input_tab(answer, allow_files, &statusbar_x, - &tabbed, refresh_func); + &tabbed, refresh_func, listed); update_the_statusbar(); } else @@ -735,7 +735,9 @@ int do_prompt(bool allow_tabs, va_list ap; int retval; functionptrtype func; - +#ifndef DISABLE_TABCOMP + bool listed = FALSE; +#endif /* Save a possible current statusbar x position. */ size_t was_statusbar_x = statusbar_x; size_t was_pww = statusbar_pww; @@ -751,7 +753,7 @@ int do_prompt(bool allow_tabs, func = get_prompt_string(&retval, allow_tabs, #ifndef DISABLE_TABCOMP - allow_files, + allow_files, &listed, #endif curranswer, #ifndef DISABLE_HISTORIES @@ -783,6 +785,13 @@ int do_prompt(bool allow_tabs, fprintf(stderr, "answer = \"%s\"\n", answer); #endif +#ifndef DISABLE_TABCOMP + /* If we've done tab completion, there might still be a list of + * filename matches on the edit window. Clear them off. */ + if (listed) + refresh_func(); +#endif + return retval; } diff --git a/src/proto.h b/src/proto.h index 5faa6e49d8a019af30f51f1fe5b406d114cd390c..6ad900b48bdddc8861c7daba72626016d98ae8dd 100644 --- a/src/proto.h +++ b/src/proto.h @@ -340,7 +340,7 @@ char **username_tab_completion(const char *buf, size_t *num_matches, char **cwd_tab_completion(const char *buf, bool allow_files, size_t *num_matches, size_t buf_len); char *input_tab(char *buf, bool allow_files, size_t *place, - bool *lastwastab, void (*refresh_func)(void)); + bool *lastwastab, void (*refresh_func)(void), bool *listed); #endif const char *tail(const char *path); #ifndef DISABLE_HISTORIES @@ -532,7 +532,7 @@ void update_the_statusbar(void); void update_bar_if_needed(void); functionptrtype get_prompt_string(int *value, bool allow_tabs, #ifndef DISABLE_TABCOMP - bool allow_files, + bool allow_files, bool *listed, #endif const char *curranswer, #ifndef DISABLE_HISTORIES