From 04082039be8caddb7b567bfa4f9d73363e4c4ba1 Mon Sep 17 00:00:00 2001 From: devangpratap <115096812+devangpratap@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:09:41 -0400 Subject: [PATCH] Fix completion of symlinks to directories for directory arguments --- tools/cli/files.go | 2 +- tools/cli/files_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/cli/files.go b/tools/cli/files.go index 453f400af..f3107f8e5 100644 --- a/tools/cli/files.go +++ b/tools/cli/files.go @@ -320,7 +320,7 @@ func DirectoryCompleter(title string, relative_to relative_to) CompletionFunc { mg.NoTrailingSpace = true mg.IsFiles = true _ = CompleteFiles(word, func(entry *FileEntry) { - if entry.Mode.IsDir() { + if entry.IsDir { mg.AddMatch(entry.CompletionCandidate) } }, cwd) diff --git a/tools/cli/files_test.go b/tools/cli/files_test.go index 3b2b1de87..030d4f53e 100644 --- a/tools/cli/files_test.go +++ b/tools/cli/files_test.go @@ -101,6 +101,14 @@ func TestCompleteFiles(t *testing.T) { t.Fatalf("Did not get %#v as a completion candidate for prefix: %#v", utils.Sep+name, prefix) } } + + // symlinks to directories are directories + os.Symlink(filepath.Join(tdir, "odir"), filepath.Join(tdir, "slink")) + c := NewCompletions() + DirectoryCompleter("", CWD)(c, "s", 0) + if len(c.Groups) != 1 || len(c.Groups[0].Matches) != 1 || c.Groups[0].Matches[0].Word != "slink/" { + t.Fatalf("Symlink to directory not completed by DirectoryCompleter: %#v", c.Groups) + } } func TestCompleteExecutables(t *testing.T) {