Skip to content

Show [0] keybinding in main view title #4754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/gui/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func (gui *Gui) resetHelpersAndControllers() {
}

for _, context := range []types.Context{
gui.State.Contexts.Status,
gui.State.Contexts.Files,
gui.State.Contexts.Branches,
gui.State.Contexts.RemoteBranches,
Expand Down
5 changes: 2 additions & 3 deletions pkg/gui/controllers/options_menu_action.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package controllers

import (
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/samber/lo"
Expand Down Expand Up @@ -61,8 +60,8 @@ func (self *OptionsMenuAction) getBindings(context types.Context) ([]*types.Bind
bindings, _ := self.c.GetInitialKeybindingsWithCustomCommands()

for _, binding := range bindings {
if keybindings.LabelFromKey(binding.Key) != "" && binding.Description != "" {
if binding.ViewName == "" {
if binding.Description != "" {
if binding.ViewName == "" || binding.Tag == "global" {
bindingsGlobal = append(bindingsGlobal, binding)
} else if binding.ViewName == context.GetViewName() {
if binding.Tag == "navigation" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (self *SwitchToFocusedMainViewController) GetKeybindings(opts types.Keybind
Key: opts.GetKey(opts.Config.Universal.FocusMainView),
Handler: self.handleFocusMainView,
Description: self.c.Tr.FocusMainView,
Tag: "global",
},
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/gui/keybindings/keybindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func Label(name string) string {
}

func LabelFromKey(key types.Key) string {
if key == nil {
return ""
}

keyInt := 0

switch key := key.(type) {
Expand Down
12 changes: 11 additions & 1 deletion pkg/gui/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,15 @@ func (gui *Gui) configureViewProperties() {
gui.Views.CommitDescription.TextArea.AutoWrapWidth = gui.c.UserConfig().Git.Commit.AutoWrapWidth

if gui.c.UserConfig().Gui.ShowPanelJumps {
keyToTitlePrefix := func(key string) string {
if key == "<disabled>" {
return ""
}
return fmt.Sprintf("[%s]", key)
}
Comment on lines +208 to +213

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix display of panel jump keys for disabled bindings
- commit subject

hi!

this handles the corresponding in this section from config docs, right?

lazygit/docs/Config.md

Lines 963 to 969 in 143d476

You can disable certain key bindings by specifying `<disabled>`.
```yaml
keybinding:
universal:
edit: <disabled> # disable 'edit file'
```

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

jumpBindings := gui.c.UserConfig().Keybinding.Universal.JumpToBlock
jumpLabels := lo.Map(jumpBindings, func(binding string, _ int) string {
return fmt.Sprintf("[%s]", binding)
return keyToTitlePrefix(binding)
})

gui.Views.Status.TitlePrefix = jumpLabels[0]
Expand All @@ -224,6 +230,8 @@ func (gui *Gui) configureViewProperties() {
gui.Views.ReflogCommits.TitlePrefix = jumpLabels[3]

gui.Views.Stash.TitlePrefix = jumpLabels[4]

gui.Views.Main.TitlePrefix = keyToTitlePrefix(gui.c.UserConfig().Keybinding.Universal.FocusMainView)
} else {
gui.Views.Status.TitlePrefix = ""

Expand All @@ -239,6 +247,8 @@ func (gui *Gui) configureViewProperties() {
gui.Views.ReflogCommits.TitlePrefix = ""

gui.Views.Stash.TitlePrefix = ""

gui.Views.Main.TitlePrefix = ""
}

for _, view := range gui.g.Views() {
Expand Down
Loading