on main help sign in
fix: ensure it's possible to quit (`ctrl+c`) even when a dialog is open (#1007)
a4da218Andrey Nering
internal/tui/tui.go+10−8
@@ -406,6 +406,16 @@ func (a *appModel) handleWindowResize(width, height int) tea.Cmd {
406
406
407// handleKeyPressMsg processes keyboard input and routes to appropriate handlers.
407// handleKeyPressMsg processes keyboard input and routes to appropriate handlers.
408func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
408func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
409+ // Check this first as the user should be able to quit no matter what.
410+ if key.Matches(msg, a.keyMap.Quit) {
411+ if a.dialog.ActiveDialogID() == quit.QuitDialogID {
412+ return tea.Quit
413+ }
414+ return util.CmdHandler(dialogs.OpenDialogMsg{
415+ Model: quit.NewQuitDialog(),
416+ })
417+ }
418+
409 if a.completions.Open() {
419 if a.completions.Open() {
410 // completions
420 // completions
411 keyMap := a.completions.KeyMap()
421 keyMap := a.completions.KeyMap()
@@ -430,14 +440,6 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
430 a.showingFullHelp = !a.showingFullHelp
440 a.showingFullHelp = !a.showingFullHelp
431 return a.handleWindowResize(a.wWidth, a.wHeight)
441 return a.handleWindowResize(a.wWidth, a.wHeight)
432 // dialogs
442 // dialogs
433− case key.Matches(msg, a.keyMap.Quit):
434− if a.dialog.ActiveDialogID() == quit.QuitDialogID {
435− return tea.Quit
436− }
437− return util.CmdHandler(dialogs.OpenDialogMsg{
438− Model: quit.NewQuitDialog(),
439− })
440−
441 case key.Matches(msg, a.keyMap.Commands):
443 case key.Matches(msg, a.keyMap.Commands):
442 // if the app is not configured show no commands
444 // if the app is not configured show no commands
443 if !a.isConfigured {
445 if !a.isConfigured {