From 36ce05e85a862f12b206a4a336fba94834f7372c Mon Sep 17 00:00:00 2001 From: CelestialCrafter Date: Fri, 22 Nov 2024 18:20:43 -0600 Subject: [PATCH] fix: handle completion info check error (#330) * fix: handle completion info check error fixes Rosettea/Hilbish#329 * make changelog more descriptive --- CHANGELOG.md | 4 ++++ complete.go | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adbf121..fd848c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 🎀 Changelog +## Unreleased +### Fixed +- Skip over file and prevent panic if info cannot be retrieved during file completion (due to permission error or anything else) + ## [2.3.3] - 2024-11-04 ### Fixed - Heredocs having issues diff --git a/complete.go b/complete.go index 1c40b20..86938cb 100644 --- a/complete.go +++ b/complete.go @@ -157,9 +157,12 @@ func matchPath(query string) ([]string, string) { files, _ := os.ReadDir(path) for _, entry := range files { - // should we handle errors here? file, err := entry.Info() - if err == nil && file.Mode() & os.ModeSymlink != 0 { + if err != nil { + continue + } + + if file.Mode() & os.ModeSymlink != 0 { path, err := filepath.EvalSymlinks(filepath.Join(path, file.Name())) if err == nil { file, err = os.Lstat(path)