From b8da81a61a1b587392359407b3d98c81158fae61 Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Sun, 17 May 2026 18:56:38 +0800 Subject: [PATCH] fix(filepicker): treat symlinked directories as navigable Fixes charmbracelet/gum#236. Resolve symlink targets when deciding if an entry is a directory so symlinks to folders can be opened instead of being selected as files. Co-authored-by: Cursor --- filepicker/filepicker.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/filepicker/filepicker.go b/filepicker/filepicker.go index 1d2a1cc2..45bc7fd9 100644 --- a/filepicker/filepicker.go +++ b/filepicker/filepicker.go @@ -385,11 +385,15 @@ func (m Model) View() string { size := strings.Replace(humanize.Bytes(uint64(info.Size())), " ", "", 1) //nolint:gosec name := f.Name() + isDir := f.IsDir() if isSymlink { symlinkPath, _ = filepath.EvalSymlinks(filepath.Join(m.CurrentDirectory, name)) + if target, err := os.Stat(symlinkPath); err == nil && target.IsDir() { + isDir = true + } } - disabled := !m.canSelect(name) && !f.IsDir() + disabled := !m.canSelect(name) && !isDir if m.selected == i { //nolint:nestif selected := "" @@ -495,7 +499,10 @@ func (m Model) didSelectFile(msg tea.Msg) (bool, string) { } } - if (!isDir && m.FileAllowed) || (isDir && m.DirAllowed) && m.Path != "" { + if isDir { + return false, "" + } + if m.FileAllowed && m.Path != "" { return true, m.Path }