From 6ce4e3ede85b91bfd2f350f22014852298fc9f57 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 19 Jun 2020 09:54:57 +0200 Subject: [PATCH] feedback: do not list "." and ".." as possible completions The single dot serves no purpose, as the user is already there. And the double dot is reached more easily by typing a second dot first. And anyway, . and .. are not shown when the user does not type a dot first, so why show them when the user types a single dot followed by ? Most likely the user wants to see actual dot files, so just show those. This fixes https://savannah.gnu.org/bugs/?58619. --- src/files.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/files.c b/src/files.c index b3f04af9..8a7ee5c1 100644 --- a/src/files.c +++ b/src/files.c @@ -2451,8 +2451,8 @@ char **filename_completion(const char *buf, size_t length, * and add each fitting one to the list of matches. */ while ((nextdir = readdir(dir)) != NULL) { if (strncmp(nextdir->d_name, filename, filenamelen) == 0 && - (*filename == '.' || (strcmp(nextdir->d_name, ".") != 0 && - strcmp(nextdir->d_name, "..") != 0))) { + strcmp(nextdir->d_name, ".") != 0 && + strcmp(nextdir->d_name, "..") != 0) { char *fullname = charalloc(strlen(dirname) + strlen(nextdir->d_name) + 1); sprintf(fullname, "%s%s", dirname, nextdir->d_name);