on main help sign in
fix(dialog): commands: execute command handlers properly
c74a5c4Ayman Bagabas
internal/ui/dialog/commands.go+5−1
@@ -149,7 +149,11 @@ func (c *Commands) Update(msg tea.Msg) tea.Msg {
149 case key.Matches(msg, c.keyMap.Select):
149 case key.Matches(msg, c.keyMap.Select):
150 if selectedItem := c.list.SelectedItem(); selectedItem != nil {
150 if selectedItem := c.list.SelectedItem(); selectedItem != nil {
151 if item, ok := selectedItem.(*CommandItem); ok && item != nil {
151 if item, ok := selectedItem.(*CommandItem); ok && item != nil {
152+ // TODO: Please unravel this mess later and the Command
153+ // Handler design.
152− return item.Cmd.Handler(item.Cmd) // Huh??
154+ if cmd := item.Cmd.Handler(item.Cmd); cmd != nil { // Huh??
155+ return cmd()
156+ }
153 }
157 }
154 }
158 }
155 case key.Matches(msg, c.keyMap.Tab):
159 case key.Matches(msg, c.keyMap.Tab):
internal/ui/model/ui.go+1
@@ -441,6 +441,7 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) (cmds []tea.Cmd) {
441 }
441 }
442 case dialog.ToggleHelpMsg:
442 case dialog.ToggleHelpMsg:
443 m.help.ShowAll = !m.help.ShowAll
443 m.help.ShowAll = !m.help.ShowAll
444+ m.dialog.RemoveDialog(dialog.CommandsID)
444 case dialog.QuitMsg:
445 case dialog.QuitMsg:
445 cmds = append(cmds, tea.Quit)
446 cmds = append(cmds, tea.Quit)
446 }
447 }