nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 0f843b007ae02e20932631096cdd3e4b10abc034
parent ff11ab6b66c223d3c7bcb04f6efd9f59118390ba
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 21 Jun 2020 10:02:45 +0200

tweaks: avoid an unnecessary refresh for zero or just one completion

Diffstat:
Msrc/files.c | 13++++++-------
Msrc/prompt.c | 3+--
2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -2483,8 +2483,6 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list size_t num_matches = 0; char **matches = NULL; - *listed = FALSE; - /* If the cursor is not at the end of the fragment, do nothing. */ if (buf[*place] != '\0') { beep(); @@ -2501,6 +2499,12 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list if (matches == NULL) matches = filename_completion(buf, *place, &num_matches); + /* If possible completions were listed before but none will be listed now... */ + if (*listed && num_matches < 2) { + refresh_func(); + *listed = FALSE; + } + if (num_matches == 0) beep(); else { @@ -2607,11 +2611,6 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list free_chararray(matches, num_matches); - /* 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; } #endif /* ENABLE_TABCOMP */ diff --git a/src/prompt.c b/src/prompt.c @@ -598,8 +598,7 @@ int do_prompt(int menu, const char *provided, linestruct **history_list, wipe_statusbar(); #ifdef ENABLE_TABCOMP - /* If we've done tab completion, there might still be a list of - * filename matches on the edit window. Clear them off. */ + /* If possible filename completions are still listed, clear them off. */ if (listed) refresh_func(); #endif