MCPcopy
hub / github.com/SurgeDM/Surge / newFilepicker

Function newFilepicker

internal/tui/model.go:669–689  ·  view source on GitHub ↗

newFilepicker creates a fresh filepicker instance with consistent settings. This is necessary to avoid cursor desync issues that cause "index out of range" panics when navigating directories (especially on Windows). See: https://github.com/charmbracelet/bubbles/issues/864

(currentDir string)

Source from the content-addressed store, hash-verified

667// panics when navigating directories (especially on Windows).
668// See: https://github.com/charmbracelet/bubbles/issues/864
669func newFilepicker(currentDir string) filepicker.Model {
670 fp := filepicker.New()
671 fp.CurrentDirectory = currentDir
672 fp.DirAllowed = true
673 fp.FileAllowed = false
674 fp.ShowHidden = false
675 fp.ShowSize = true
676 fp.ShowPermissions = true
677 fp.SetHeight(FilePickerHeight)
678
679 // Re-bind Select and Open to '.' per user preference.
680 // We also keep 'right' for Open to allow directory navigation.
681 fp.KeyMap.Select = key.NewBinding(key.WithKeys("."))
682 fp.KeyMap.Open = key.NewBinding(key.WithKeys(".", "right"))
683 // Keep ESC reserved for dismissing the modal; use left/backspace/h to go up.
684 fp.KeyMap.Back = key.NewBinding(key.WithKeys("h", "backspace", "left"))
685
686 applyFilepickerTheme(&fp)
687
688 return fp
689}
690
691// ApplyTheme applies the selected theme mode
692func (m *RootModel) ApplyTheme(mode int, path string) {

Calls 1

applyFilepickerThemeFunction · 0.85