From c3715d0f86b3278e4a3c193c4426ee4a6af88a95 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 27 Jun 2024 14:36:18 +0200 Subject: [PATCH 1/2] Extract helper function SuggestionsController.switchToConfirmation This fixes the minor issue that the subtitle of the suggestions view wasn't emptied when hitting "e" to edit a custom command. --- pkg/gui/controllers/suggestions_controller.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/gui/controllers/suggestions_controller.go b/pkg/gui/controllers/suggestions_controller.go index 857952d9b..90ac43107 100644 --- a/pkg/gui/controllers/suggestions_controller.go +++ b/pkg/gui/controllers/suggestions_controller.go @@ -40,11 +40,8 @@ func (self *SuggestionsController) GetKeybindings(opts types.KeybindingsOpts) [] Handler: func() error { return self.context().State.OnClose() }, }, { - Key: opts.GetKey(opts.Config.Universal.TogglePanel), - Handler: func() error { - self.c.Views().Suggestions.Subtitle = "" - return self.c.ReplaceContext(self.c.Contexts().Confirmation) - }, + Key: opts.GetKey(opts.Config.Universal.TogglePanel), + Handler: self.switchToConfirmation, }, { Key: opts.GetKey(opts.Config.Universal.Remove), @@ -61,7 +58,7 @@ func (self *SuggestionsController) GetKeybindings(opts types.KeybindingsOpts) [] self.c.Contexts().Confirmation.GetView().TextArea.TypeString(selectedItem.Value) self.c.Contexts().Confirmation.GetView().RenderTextArea() self.c.Contexts().Suggestions.RefreshSuggestions() - return self.c.ReplaceContext(self.c.Contexts().Confirmation) + return self.switchToConfirmation() } } return nil @@ -72,6 +69,11 @@ func (self *SuggestionsController) GetKeybindings(opts types.KeybindingsOpts) [] return bindings } +func (self *SuggestionsController) switchToConfirmation() error { + self.c.Views().Suggestions.Subtitle = "" + return self.c.ReplaceContext(self.c.Contexts().Confirmation) +} + func (self *SuggestionsController) GetOnFocusLost() func(types.OnFocusLostOpts) error { return func(types.OnFocusLostOpts) error { self.c.Helpers().Confirmation.DeactivateConfirmationPrompt() From 9b73b68f95399e90da501a0be9d751c7d893a413 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 27 Jun 2024 14:45:29 +0200 Subject: [PATCH 2/2] Turn off the highlight of the suggestions panel when it loses focus The highlight is normally turned off in HandleFocusLost, but that's not called when using ReplaceContext (and changing this would be a lot of work, it seems), so turn it off manually here for now. --- pkg/gui/controllers/suggestions_controller.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/gui/controllers/suggestions_controller.go b/pkg/gui/controllers/suggestions_controller.go index 90ac43107..a425f356e 100644 --- a/pkg/gui/controllers/suggestions_controller.go +++ b/pkg/gui/controllers/suggestions_controller.go @@ -71,6 +71,7 @@ func (self *SuggestionsController) GetKeybindings(opts types.KeybindingsOpts) [] func (self *SuggestionsController) switchToConfirmation() error { self.c.Views().Suggestions.Subtitle = "" + self.c.Views().Suggestions.Highlight = false return self.c.ReplaceContext(self.c.Contexts().Confirmation) }