And more corner cases

This commit is contained in:
Kovid Goyal 2022-09-15 20:35:05 +05:30
parent ced741b247
commit 6faa908733
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -29,9 +29,12 @@ type CompleteFilesCallback func(completion_candidate, abspath string, d fs.DirEn
func complete_files(prefix string, callback CompleteFilesCallback) error {
base := prefix
if base != "~" && base != "./" {
if strings.Contains(base, string(os.PathSeparator)) {
base = filepath.Dir(base)
if base != "~" && base != "./" && base != "/" {
// cant use filepath.Dir() as it calls filepath.Clean() which
// can cause base to no longer match prefix
idx := strings.LastIndex(base, string(os.PathSeparator))
if idx > 0 {
base = base[:idx]
} else {
base = ""
}