Merge branch 'fix-case-insensitive-completion-matching' of https://github.com/devangpratap/kitty

This commit is contained in:
Kovid Goyal 2026-09-16 10:56:25 +05:30
commit 50eaaf5d15
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 1 deletions

View file

@ -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
}

View file

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