Skip to content

Commit

Permalink
Show delete/edit keybindings in suggestions subtitle if available
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaller committed May 17, 2024
1 parent fdb7beb commit f4231fd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions pkg/gui/controllers/confirmation_controller.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package controllers

import (
"fmt"

"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/gui/controllers/helpers/confirmation_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 7 additions & 2 deletions pkg/gui/controllers/suggestions_controller.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package controllers

import (
"fmt"

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / build

"fmt" imported and not used

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / Integration Tests - git 2.20.0

"fmt" imported and not used

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / Integration Tests - git 2.22.5

"fmt" imported and not used

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / lint

"fmt" imported and not used) (typecheck)

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / lint

"fmt" imported and not used (typecheck)

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / lint

"fmt" imported and not used) (typecheck)

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / lint

"fmt" imported and not used (typecheck)

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / Integration Tests - git 2.23.0

"fmt" imported and not used

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / ci - ubuntu-latest

"fmt" imported and not used

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / Integration Tests - git 2.25.1

"fmt" imported and not used

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / ci - windows-latest

"fmt" imported and not used

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / Integration Tests - git 2.30.8

"fmt" imported and not used

Check failure on line 4 in pkg/gui/controllers/suggestions_controller.go

View workflow job for this annotation

GitHub Actions / Integration Tests - git latest

"fmt" imported and not used

"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
Expand Down Expand Up @@ -40,8 +42,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),
Expand Down
2 changes: 2 additions & 0 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit f4231fd

Please sign in to comment.