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) {