mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-21 04:32:05 +00:00
Fix completion of paths directly under the root directory
This commit is contained in:
parent
bab67650e2
commit
fd904d45d8
2 changed files with 13 additions and 1 deletions
|
|
@ -65,7 +65,7 @@ func CompleteFiles(prefix string, callback func(*FileEntry), cwd string) error {
|
|||
joinable_prefix = prefix
|
||||
} else {
|
||||
idx := strings.LastIndex(prefix, utils.Sep)
|
||||
if idx > 0 {
|
||||
if idx > -1 {
|
||||
joinable_prefix = prefix[:idx+1]
|
||||
base_dir = filepath.Dir(location)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,18 @@ func TestCompleteFiles(t *testing.T) {
|
|||
test_candidates("odir/f", "odir/four.txt")
|
||||
test_candidates("x")
|
||||
|
||||
// a prefix whose only separator is the leading one, such as /us
|
||||
if entries, err := os.ReadDir(utils.Sep); err == nil && len(entries) > 0 {
|
||||
name := entries[0].Name()
|
||||
prefix := utils.Sep + name[:1]
|
||||
found := false
|
||||
CompleteFiles(prefix, func(entry *FileEntry) {
|
||||
found = found || strings.TrimSuffix(entry.CompletionCandidate, utils.Sep) == utils.Sep+name
|
||||
}, "")
|
||||
if !found {
|
||||
t.Fatalf("Did not get %#v as a completion candidate for prefix: %#v", utils.Sep+name, prefix)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteExecutables(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue