From 74986eb00d716af3f0dd3be44f78d3badb68a0a1 Mon Sep 17 00:00:00 2001 From: Dominik Agres Date: Sun, 30 Nov 2025 23:49:28 +0100 Subject: [PATCH] fixed not remembering which menu was selected beforhand and therefore the tui would not behave consistently --- src/tui.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tui.go b/src/tui.go index 49288d2..79d207b 100644 --- a/src/tui.go +++ b/src/tui.go @@ -30,6 +30,7 @@ type model struct { currentView view currentKey string selectedCmd string + categoryIndex int } func (m model) Init() tea.Cmd { return nil } @@ -48,10 +49,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { selected, ok := m.list.SelectedItem().(item) if ok { if m.currentView == viewCategories { + m.categoryIndex = m.list.Index() m.currentKey = selected.title m.currentView = viewCommands m.list.Title = m.currentKey m.list.SetItems(cmdItemsToList(m.commands.Get(m.currentKey))) + m.list.Select(0) } else if m.currentView == viewCommands { m.selectedCmd = selected.title return m, tea.Quit @@ -64,6 +67,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.currentView = viewCategories m.list.Title = "Choose a list of commands" m.list.SetItems(cmdListKeysToList(m.commands)) + m.list.Select(m.categoryIndex) } }