diff --git a/tools/cli/files.go b/tools/cli/files.go index f3107f8e5..963c2b31c 100644 --- a/tools/cli/files.go +++ b/tools/cli/files.go @@ -156,7 +156,7 @@ func fname_based_completer(prefix, cwd string, is_match func(string) bool) []str entries, err := os.ReadDir(entry.Abspath) if err == nil { for _, e := range entries { - if is_match(e.Name()) || is_dir_or_symlink_to_dir(e, filepath.Join(entry.Abspath, e.Name())) { + if is_match(strings.ToLower(e.Name())) || is_dir_or_symlink_to_dir(e, filepath.Join(entry.Abspath, e.Name())) { ans = append(ans, entry.CompletionCandidate) return } diff --git a/tools/cli/files_test.go b/tools/cli/files_test.go index 030d4f53e..486b9a19e 100644 --- a/tools/cli/files_test.go +++ b/tools/cli/files_test.go @@ -109,6 +109,21 @@ func TestCompleteFiles(t *testing.T) { 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) } + + // filenames inside a directory are matched case-insensitively against patterns + os.Mkdir(filepath.Join(tdir, "cdir"), 0700) + create("cdir", "B.CONF") + c = NewCompletions() + FnmatchCompleter("", CWD, "*.conf")(c, "c", 0) + found := false + for _, g := range c.Groups { + for _, m := range g.Matches { + found = found || m.Word == "cdir/" + } + } + if !found { + t.Fatalf("Directory containing only an uppercase extension match not completed by FnmatchCompleter: %#v", c.Groups) + } } func TestCompleteExecutables(t *testing.T) {