commit c7356c2d8544ef8b1f8b0772f525055c1716070e
parent 91ba76e1e0c807e2625d5369733644a1829d77e9
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 21 Jun 2020 10:44:05 +0200
files: show possible tab completions near the bottom of the edit window
Especially when it are just a handful of possible completions, it is
much nicer to have them listed close to the prompt bar where the eyes
of the user are.
This fulfills https://savannah.gnu.org/bugs/?58620.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -2559,8 +2559,9 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list
/* If there is more than one possible completion, show a sorted list. */
if (num_matches > 1) {
- size_t longest_name = 0, ncols;
- int row = 0;
+ size_t longest_name = 0;
+ size_t nrows, ncols;
+ int row;
qsort(matches, num_matches, sizeof(char *), diralphasort);
@@ -2578,6 +2579,9 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list
/* The columns of names will be separated by two spaces,
* but the last column will have just one space after it. */
ncols = (COLS + 1) / (longest_name + 2);
+ nrows = (num_matches + ncols - 1) / ncols;
+
+ row = (nrows < editwinrows - 1) ? editwinrows - nrows - 1 : 0;
/* Blank the edit window and hide the cursor. */
blank_edit();