files: list possible completions after just one <Tab> instead of two

This gives quicker feedback, and spares the user unnecessary beeps
and typing.  Also, now a beep after a <Tab> means just one thing:
there are NO completions.

This fulfills https://savannah.gnu.org/bugs/?58627.
master
Benno Schulenberg 2020-06-20 18:40:36 +02:00
parent 096e36279f
commit ff11ab6b66
3 changed files with 4 additions and 18 deletions

View File

@ -2478,8 +2478,7 @@ char **filename_completion(const char *buf, size_t length, size_t *num_matches)
/* Do tab completion. 'place' is the position of the status-bar cursor, and
* 'refresh_func' is the function to be called to refresh the edit window. */
char *input_tab(char *buf, size_t *place, bool *lastwastab,
void (*refresh_func)(void), bool *listed)
char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *listed)
{
size_t num_matches = 0;
char **matches = NULL;
@ -2544,9 +2543,6 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab,
if (num_matches == 1 && (is_dir(mzero) || is_dir(glued)))
mzero[common_len++] = '/';
if (num_matches > 1 && (common_len != *place || !*lastwastab))
beep();
/* If the matches have something in common, show that part. */
if (common_len != *place) {
buf = charealloc(buf, common_len + 1);
@ -2555,9 +2551,7 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab,
*place = common_len;
}
if (!*lastwastab)
*lastwastab = TRUE;
else if (num_matches > 1) {
if (num_matches > 1) {
size_t longest_name = 0, ncols;
int row = 0;

View File

@ -409,10 +409,6 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
int kbinput = ERR;
bool finished;
functionptrtype func;
#ifdef ENABLE_TABCOMP
bool tabbed = FALSE;
/* Whether we've pressed Tab. */
#endif
#ifdef ENABLE_HISTORIES
char *history = NULL;
/* The current history string. */
@ -453,9 +449,6 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
break;
#ifdef ENABLE_TABCOMP
if (func != do_tab)
tabbed = FALSE;
if (func == do_tab) {
#ifdef ENABLE_HISTORIES
if (history_list != NULL) {
@ -472,7 +465,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
/* Allow tab completion of filenames, but not in restricted mode. */
if ((currmenu == MINSERTFILE || currmenu == MWRITEFILE ||
currmenu == MGOTODIR) && !ISSET(RESTRICTED))
answer = input_tab(answer, &typing_x, &tabbed, refresh_func, listed);
answer = input_tab(answer, &typing_x, refresh_func, listed);
} else
#endif /* ENABLE_TABCOMP */
#ifdef ENABLE_HISTORIES

View File

@ -320,8 +320,7 @@ char *real_dir_from_tilde(const char *path);
int diralphasort(const void *va, const void *vb);
#endif
#ifdef ENABLE_TABCOMP
char *input_tab(char *buf, size_t *place, bool *lastwastab,
void (*refresh_func)(void), bool *listed);
char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *listed);
#endif
/* Some functions in global.c. */