summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-05-17 18:13:16 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-05-19 07:06:18 +0200
commit010b0ae923360ccaaed34cce6301966bb7c9c9ed (patch)
treef28d26ceed1bcb8d48c7176dd8850f25c78181e9 /pkg
parenta7041cf492cb24bfd2bbaed0df5d91a943b78ca0 (diff)
Show delete/edit keybindings in suggestions subtitle if available
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/controllers/confirmation_controller.go10
-rw-r--r--pkg/gui/controllers/helpers/confirmation_helper.go1
-rw-r--r--pkg/gui/controllers/suggestions_controller.go7
-rw-r--r--pkg/i18n/english.go2
4 files changed, 18 insertions, 2 deletions
diff --git a/pkg/gui/controllers/confirmation_controller.go b/pkg/gui/controllers/confirmation_controller.go
index aa5617fa8..45bd16a45 100644
--- a/pkg/gui/controllers/confirmation_controller.go
+++ b/pkg/gui/controllers/confirmation_controller.go
@@ -1,6 +1,8 @@
package controllers
import (
+ "fmt"
+
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
@@ -39,6 +41,14 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [
Key: opts.GetKey(opts.Config.Universal.TogglePanel),
Handler: func() error {
if len(self.c.Contexts().Suggestions.State.Suggestions) > 0 {
+ subtitle := ""
+ if self.c.State().GetRepoState().GetCurrentPopupOpts().HandleDeleteSuggestion != nil {
+ // We assume that whenever things are deletable, they
+ // are also editable, so we show both keybindings
+ subtitle = fmt.Sprintf(self.c.Tr.SuggestionsSubtitle,
+ self.c.UserConfig.Keybinding.Universal.Remove, self.c.UserConfig.Keybinding.Universal.Edit)
+ }
+ self.c.Views().Suggestions.Subtitle = subtitle
return self.c.ReplaceContext(self.c.Contexts().Suggestions)
}
return nil
diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go
index e4b76ce40..b5a337fbb 100644
--- a/pkg/gui/controllers/helpers/confirmation_helper.go
+++ b/pkg/gui/controllers/helpers/confirmation_helper.go
@@ -159,6 +159,7 @@ func (self *ConfirmationHelper) prepareConfirmationPanel(
suggestionsContext.SetSuggestions(opts.FindSuggestionsFunc(""))
suggestionsView.Visible = true
suggestionsView.Title = fmt.Sprintf(self.c.Tr.SuggestionsTitle, self.c.UserConfig.Keybinding.Universal.TogglePanel)
+ suggestionsView.Subtitle = ""
}
self.ResizeConfirmationPanel()
diff --git a/pkg/gui/controllers/suggestions_controller.go b/pkg/gui/controllers/suggestions_controller.go
index 655c7465b..857952d9b 100644
--- a/pkg/gui/controllers/suggestions_controller.go
+++ b/pkg/gui/controllers/suggestions_controller.go
@@ -40,8 +40,11 @@ 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 { return self.c.ReplaceContext(self.c.Contexts().Confirmation) },
+ 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.Remove),
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 27905cf9b..caa920de1 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -631,6 +631,7 @@ type TranslationSet struct {
SuggestionsCheatsheetTitle string
// Unlike the cheatsheet title above, the real suggestions title has a little message saying press tab to focus
SuggestionsTitle string
+ SuggestionsSubtitle string
ExtrasTitle string
PushingTagStatus string
PullRequestURLCopiedToClipboard string
@@ -1593,6 +1594,7 @@ func EnglishTranslationSet() TranslationSet {
NavigationTitle: "List panel navigation",
SuggestionsCheatsheetTitle: "Suggestions",
SuggestionsTitle: "Suggestions (press %s to focus)",
+ SuggestionsSubtitle: "(press %s to delete, %s to edit)",
ExtrasTitle: "Command log",
PushingTagStatus: "Pushing tag",
PullRequestURLCopiedToClipboard: "Pull request URL copied to clipboard",