From 26dcc7d1b7cf1d3fc33f9c5d6e26239f64e8e893 Mon Sep 17 00:00:00 2001 From: lorenries Date: Mon, 7 Feb 2022 23:38:57 -0500 Subject: [PATCH] fix(list): disable quit keybinding while filtering --- list/list.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/list/list.go b/list/list.go index e18cc71f..9380e0e9 100644 --- a/list/list.go +++ b/list/list.go @@ -107,6 +107,8 @@ type Model struct { // Key mappings for navigating the list. KeyMap KeyMap + disableQuitKeybindings bool + // Additional key mappings for the short and full help views. This allows // you to add additional key mappings to the help menu without // re-implementing the help component. Of course, you can also disable the @@ -521,6 +523,7 @@ func (m *Model) StopSpinner() { // Helper for disabling the keybindings used for quitting, incase you want to // handle this elsewhere in your application. func (m *Model) DisableQuitKeybindings() { + m.disableQuitKeybindings = true m.KeyMap.Quit.SetEnabled(false) m.KeyMap.ForceQuit.SetEnabled(false) } @@ -591,7 +594,6 @@ func (m Model) itemsAsFilterItems() filteredItems { // Set keybindings according to the filter state. func (m *Model) updateKeybindings() { - quit := m.KeyMap.Quit.Enabled() switch m.filterState { case Filtering: m.KeyMap.CursorUp.SetEnabled(false) @@ -624,6 +626,7 @@ func (m *Model) updateKeybindings() { m.KeyMap.ClearFilter.SetEnabled(m.filterState == FilterApplied) m.KeyMap.CancelWhileFiltering.SetEnabled(false) m.KeyMap.AcceptWhileFiltering.SetEnabled(false) + m.KeyMap.Quit.SetEnabled(!m.disableQuitKeybindings) if m.Help.ShowAll { m.KeyMap.ShowFullHelp.SetEnabled(true) @@ -634,7 +637,6 @@ func (m *Model) updateKeybindings() { m.KeyMap.CloseFullHelp.SetEnabled(minHelp) } } - m.KeyMap.Quit.SetEnabled(quit) } // Update pagination according to the amount of items for the current state.