From b766ff9c831650a3598e904073a3c3796b38ad68 Mon Sep 17 00:00:00 2001 From: Chris McDonnell Date: Thu, 20 Feb 2025 13:02:33 -0500 Subject: [PATCH 1/2] Disable global keybinds while popups are active --- pkg/gui/controllers/global_controller.go | 14 ++++---- .../jump_to_side_window_controller.go | 2 +- pkg/gui/keybindings.go | 8 ++--- pkg/integration/tests/test_list.go | 1 - pkg/integration/tests/ui/double_popup.go | 34 ------------------- 5 files changed, 12 insertions(+), 47 deletions(-) delete mode 100644 pkg/integration/tests/ui/double_popup.go diff --git a/pkg/gui/controllers/global_controller.go b/pkg/gui/controllers/global_controller.go index 818a31178..6fa6fefef 100644 --- a/pkg/gui/controllers/global_controller.go +++ b/pkg/gui/controllers/global_controller.go @@ -36,25 +36,25 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type }, { Key: opts.GetKey(opts.Config.Universal.CreateRebaseOptionsMenu), - Handler: self.c.Helpers().MergeAndRebase.CreateRebaseOptionsMenu, + Handler: opts.Guards.NoPopupPanel(self.c.Helpers().MergeAndRebase.CreateRebaseOptionsMenu), Description: self.c.Tr.ViewMergeRebaseOptions, Tooltip: self.c.Tr.ViewMergeRebaseOptionsTooltip, OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Universal.Refresh), - Handler: self.refresh, + Handler: opts.Guards.NoPopupPanel(self.refresh), Description: self.c.Tr.Refresh, Tooltip: self.c.Tr.RefreshTooltip, }, { Key: opts.GetKey(opts.Config.Universal.NextScreenMode), - Handler: self.nextScreenMode, + Handler: opts.Guards.NoPopupPanel(self.nextScreenMode), Description: self.c.Tr.NextScreenMode, }, { Key: opts.GetKey(opts.Config.Universal.PrevScreenMode), - Handler: self.prevScreenMode, + Handler: opts.Guards.NoPopupPanel(self.prevScreenMode), Description: self.c.Tr.PrevScreenMode, }, { @@ -78,21 +78,21 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type { ViewName: "", Key: opts.GetKey(opts.Config.Universal.FilteringMenu), - Handler: self.createFilteringMenu, + Handler: opts.Guards.NoPopupPanel(self.createFilteringMenu), Description: self.c.Tr.OpenFilteringMenu, Tooltip: self.c.Tr.OpenFilteringMenuTooltip, OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Universal.DiffingMenu), - Handler: self.createDiffingMenu, + Handler: opts.Guards.NoPopupPanel(self.createDiffingMenu), Description: self.c.Tr.ViewDiffingOptions, Tooltip: self.c.Tr.ViewDiffingOptionsTooltip, OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Universal.DiffingMenuAlt), - Handler: self.createDiffingMenu, + Handler: opts.Guards.NoPopupPanel(self.createDiffingMenu), Description: self.c.Tr.ViewDiffingOptions, Tooltip: self.c.Tr.ViewDiffingOptionsTooltip, OpensMenu: true, diff --git a/pkg/gui/controllers/jump_to_side_window_controller.go b/pkg/gui/controllers/jump_to_side_window_controller.go index 39120eda8..0cbbc6c85 100644 --- a/pkg/gui/controllers/jump_to_side_window_controller.go +++ b/pkg/gui/controllers/jump_to_side_window_controller.go @@ -42,7 +42,7 @@ func (self *JumpToSideWindowController) GetKeybindings(opts types.KeybindingsOpt // by default the keys are 1, 2, 3, etc Key: opts.GetKey(opts.Config.Universal.JumpToBlock[index]), Modifier: gocui.ModNone, - Handler: self.goToSideWindow(window), + Handler: opts.Guards.NoPopupPanel(self.goToSideWindow(window)), } }) } diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 300d8440e..20163b90b 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -83,7 +83,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi { ViewName: "", Key: opts.GetKey(opts.Config.Universal.OpenRecentRepos), - Handler: self.helpers.Repos.CreateRecentReposMenu, + Handler: opts.Guards.NoPopupPanel(self.helpers.Repos.CreateRecentReposMenu), Description: self.c.Tr.SwitchRepo, }, { @@ -195,7 +195,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi { ViewName: "", Key: opts.GetKey(opts.Config.Universal.ExtrasMenu), - Handler: self.handleCreateExtrasMenuPanel, + Handler: opts.Guards.NoPopupPanel(self.handleCreateExtrasMenuPanel), Description: self.c.Tr.OpenCommandLogMenu, Tooltip: self.c.Tr.OpenCommandLogMenuTooltip, OpensMenu: true, @@ -330,14 +330,14 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi { ViewName: "", Key: opts.GetKey(opts.Config.Universal.NextTab), - Handler: self.handleNextTab, + Handler: opts.Guards.NoPopupPanel(self.handleNextTab), Description: self.c.Tr.NextTab, Tag: "navigation", }, { ViewName: "", Key: opts.GetKey(opts.Config.Universal.PrevTab), - Handler: self.handlePrevTab, + Handler: opts.Guards.NoPopupPanel(self.handlePrevTab), Description: self.c.Tr.PrevTab, Tag: "navigation", }, diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index d0dc2a8a0..573daade1 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -371,7 +371,6 @@ var tests = []*components.IntegrationTest{ tag.Reset, ui.Accordion, ui.DisableSwitchTabWithPanelJumpKeys, - ui.DoublePopup, ui.EmptyMenu, ui.KeybindingSuggestionsWhenSwitchingRepos, ui.ModeSpecificKeybindingSuggestions, diff --git a/pkg/integration/tests/ui/double_popup.go b/pkg/integration/tests/ui/double_popup.go deleted file mode 100644 index 2d6b7fe20..000000000 --- a/pkg/integration/tests/ui/double_popup.go +++ /dev/null @@ -1,34 +0,0 @@ -package ui - -import ( - "github.com/jesseduffield/lazygit/pkg/config" - . "github.com/jesseduffield/lazygit/pkg/integration/components" -) - -var DoublePopup = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Open a popup from within another popup and assert you can escape back to the side panels", - ExtraCmdArgs: []string{}, - Skip: false, - SetupConfig: func(config *config.AppConfig) {}, - SetupRepo: func(shell *Shell) { - shell.EmptyCommit("one") - }, - Run: func(t *TestDriver, keys config.KeybindingConfig) { - t.Views().Branches(). - Focus(). - // arbitrarily bringing up a popup - PressPrimaryAction() - - t.ExpectPopup().Alert(). - Title(Contains("Error")). - Content(Contains("You have already checked out this branch")) - - t.GlobalPress(keys.Universal.OpenRecentRepos) - - t.ExpectPopup().Menu().Title(Contains("Recent repositories")).Cancel() - - t.Views().Branches().IsFocused() - - t.Views().Files().Focus() - }, -}) From 0ef3832e59864e7f32934de03ba44e1ad03abb50 Mon Sep 17 00:00:00 2001 From: Chris McDonnell Date: Thu, 20 Feb 2025 13:11:18 -0500 Subject: [PATCH 2/2] docs: Add reference to confirmation key to intro message --- pkg/gui/gui.go | 9 ++++++++- pkg/i18n/english.go | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 51a1bf2c7..cf62011ca 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -1012,9 +1012,16 @@ func (gui *Gui) showIntroPopupMessage() { return err } + introMessage := utils.ResolvePlaceholderString( + gui.c.Tr.IntroPopupMessage, + map[string]string{ + "confirmationKey": gui.c.UserConfig().Keybinding.Universal.Confirm, + }, + ) + gui.c.Confirm(types.ConfirmOpts{ Title: "", - Prompt: gui.c.Tr.IntroPopupMessage, + Prompt: introMessage, HandleConfirm: onConfirm, HandleClose: onConfirm, }) diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 3bd2ca528..f4a781c9a 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1019,6 +1019,8 @@ Thanks for using lazygit! Seriously you rock. Three things to share with you: You can also sponsor me and tell me what to work on by clicking the donate button at the bottom right. Or even just star the repo to share the love! + +Press {{confirmationKey}} to get started. ` const englishDeprecatedEditConfigWarning = `