1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

Show [0] keybinding in main view title (#4754)

- **PR Description**

Show the `[0]` keybinding in the title of the main view, to make it more
discoverable.

Also, move it to the "global" section of the keybindings menu.

And several minor fixes and cleanups, see individual commits for
details.

Fixes #4738.
This commit is contained in:
Stefan Haller
2025-07-27 12:29:50 +02:00
committed by GitHub
14 changed files with 28 additions and 4 deletions

View File

@ -340,6 +340,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` u `` | Check for update | |
| `` <enter> `` | Switch to a recent repo | |
| `` a `` | Show/cycle all branch logs | |
| `` 0 `` | Focus main view | |
## Sub-commits

View File

@ -175,6 +175,7 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味
| `` u `` | 更新を確認 | |
| `` <enter> `` | 最近のリポジトリをチェックアウト | |
| `` a `` | ブランチログの表示モードを順に切り替え | |
| `` 0 `` | Focus main view | |
## セカンダリ

View File

@ -233,6 +233,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` u `` | 업데이트 확인 | |
| `` <enter> `` | 최근에 사용한 저장소로 전환 | |
| `` a `` | Show/cycle all branch logs | |
| `` 0 `` | Focus main view | |
## 서브모듈

View File

@ -340,6 +340,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` u `` | Check voor updates | |
| `` <enter> `` | Wissel naar een recente repo | |
| `` a `` | Show/cycle all branch logs | |
| `` 0 `` | Focus main view | |
## Sub-commits

View File

@ -320,6 +320,7 @@ _Legenda: `<c-b>` oznacza ctrl+b, `<a-b>` oznacza alt+b, `B` oznacza shift+b_
| `` u `` | Sprawdź aktualizacje | |
| `` <enter> `` | Przełącz na ostatnie repozytorium | |
| `` a `` | Show/cycle all branch logs | |
| `` 0 `` | Focus main view | |
## Sub-commity

View File

@ -349,6 +349,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` u `` | Verificar atualização | |
| `` <enter> `` | Mudar para um repositório recente | |
| `` a `` | Mostrar/ciclo todos os logs de filiais | |
| `` 0 `` | Focus main view | |
## Sub-commits

View File

@ -307,6 +307,7 @@ _Связки клавиш_
| `` u `` | Проверить обновления | |
| `` <enter> `` | Переключиться на последний репозиторий | |
| `` a `` | Show/cycle all branch logs | |
| `` 0 `` | Focus main view | |
## Теги

View File

@ -341,6 +341,7 @@ _图例:`<c-b>` 意味着ctrl+b, `<a-b>意味着Alt+b, `B` 意味着shift+b_
| `` u `` | 检查更新 | |
| `` <enter> `` | 切换到最近的仓库 | |
| `` a `` | 显示/循环所有分支日志 | |
| `` 0 `` | Focus main view | |
## 确认面板

View File

@ -363,6 +363,7 @@ _說明:`<c-b>` 表示 Ctrl+B、`<a-b>` 表示 Alt+B,`B`表示 Shift+B
| `` u `` | 檢查更新 | |
| `` <enter> `` | 切換到最近使用的版本庫 | |
| `` a `` | Show/cycle all branch logs | |
| `` 0 `` | Focus main view | |
## 確認面板

View File

@ -260,6 +260,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,

View File

@ -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"
@ -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" {

View File

@ -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",
},
}

View File

@ -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) {

View File

@ -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)
}
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]
@ -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 = ""
@ -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() {