From ca84300ef3635f1d849fca70be1ca33c3bbfd713 Mon Sep 17 00:00:00 2001 From: Samuel Recker Date: Mon, 16 Jan 2023 22:42:36 +0100 Subject: [PATCH] fix help in new_installation, follow symlinks --- tea/scenes/new_installation.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tea/scenes/new_installation.go b/tea/scenes/new_installation.go index 679e4df..26398db 100644 --- a/tea/scenes/new_installation.go +++ b/tea/scenes/new_installation.go @@ -3,6 +3,7 @@ package scenes import ( "fmt" "io" + "io/fs" "os" "path/filepath" "sort" @@ -42,8 +43,16 @@ func NewNewInstallation(root components.RootModel, parent tea.Model) tea.Model { l.SetShowTitle(false) l.Styles = utils.ListStyles l.SetSize(l.Width(), l.Height()) - l.KeyMap.Quit.SetHelp("esc", "back") l.SetShowStatusBar(false) + l.KeyMap.ShowFullHelp.Unbind() + l.KeyMap.Quit.SetHelp("esc", "back") + l.KeyMap.CursorDown.SetHelp("↓", "down") + l.KeyMap.CursorUp.SetHelp("↑", "up") + l.AdditionalShortHelpKeys = func() []key.Binding { + return []key.Binding{ + key.NewBinding(key.WithKeys(KeyTab), key.WithHelp(KeyTab, "select")), + } + } model := newInstallation{ root: root, @@ -167,7 +176,7 @@ func (m newInstallation) View() string { } m.dirList.SetSize(m.dirList.Width(), m.root.Size().Height-lipgloss.Height(mandatory)-1) - return lipgloss.JoinVertical(lipgloss.Left, mandatory, style.Render(m.dirList.View())) + return lipgloss.JoinVertical(lipgloss.Left, mandatory, m.dirList.View()) } // I know this is awful, but beats re-implementing the entire list model @@ -191,7 +200,7 @@ func getDirItems(inputValue string) []list.Item { if filter != "" { dirNames := make([]string, 0) for _, entry := range dir { - if entry.IsDir() { + if entry.IsDir() || entry.Type() == fs.ModeSymlink { dirNames = append(dirNames, entry.Name()) } } @@ -211,7 +220,7 @@ func getDirItems(inputValue string) []list.Item { globalMatches = matches } else { for _, entry := range dir { - if entry.IsDir() { + if entry.IsDir() || entry.Type() == fs.ModeSymlink { newItems = append(newItems, utils.SimpleItemExtra[newInstallation, string]{ SimpleItem: utils.SimpleItem[newInstallation]{ ItemTitle: entry.Name(),