tabbing: refresh the edit window in case a previous tab listed names

Commit 36ec76a made the wrong change: after a tab that did not list any
file names on the screen, a refresh /is/ needed, because a previous tab
might have listed things on the screen.  But at the end of the prompt,
it is not necessary to refresh the edit window if things were listed,
because the window will be refreshed anyway after reading in a file.
master
Benno Schulenberg 2016-04-23 15:38:40 +02:00
parent 553b7af355
commit 41ed690791
3 changed files with 14 additions and 20 deletions

View File

@ -2756,15 +2756,14 @@ 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, bool *listed)
bool *lastwastab, void (*refresh_func)(void))
{
size_t num_matches = 0, buf_len;
char **matches = NULL;
bool listed = FALSE;
assert(buf != NULL && place != NULL && *place <= strlen(buf) &&
lastwastab != NULL && listed != NULL);
*listed = FALSE;
lastwastab != NULL && refresh_func != NULL);
/* If the word starts with `~' and there is no slash in the word,
* then try completing this word as a username. */
@ -2897,7 +2896,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
}
wnoutrefresh(edit);
*listed = TRUE;
listed = TRUE;
}
free(mzero);
@ -2905,6 +2904,10 @@ 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)
refresh_func();
return buf;
}
#endif /* !DISABLE_TABCOMP */

View File

@ -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 *listed,
bool allow_files,
#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, listed);
&tabbed, refresh_func);
update_the_statusbar();
} else
@ -735,9 +735,7 @@ 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;
@ -753,7 +751,7 @@ int do_prompt(bool allow_tabs,
func = get_prompt_string(&retval, allow_tabs,
#ifndef DISABLE_TABCOMP
allow_files, &listed,
allow_files,
#endif
curranswer,
#ifndef DISABLE_HISTORIES
@ -785,13 +783,6 @@ int do_prompt(bool allow_tabs,
fprintf(stderr, "answer = \"%s\"\n", answer);
#endif
#ifndef DISABLE_TABCOMP
/* If we've done tab completion, and a list of filename matches
* was printed in the edit window, clear them off. */
if (listed)
refresh_func();
#endif
return retval;
}

View File

@ -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, bool *listed);
bool *lastwastab, void (*refresh_func)(void));
#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 *listed,
bool allow_files,
#endif
const char *curranswer,
#ifndef DISABLE_HISTORIES