diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index 435f48806..cee94e0a3 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -20,6 +20,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct @: open command log menu }: Increase the size of the context shown around changes in the diff view {: Decrease the size of the context shown around changes in the diff view + :: execute custom command z: undo (via reflog) (experimental) ctrl+z: redo (via reflog) (experimental) P: push @@ -41,6 +42,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Branches Panel (Branches Tab)
+  i: show git-flow options
+  ctrl+o: copy branch name to clipboard
   space: checkout
   o: create pull request
   O: create pull request options
@@ -51,11 +54,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   d: delete branch
   r: rebase checked-out branch onto this branch
   M: merge into currently checked out branch
-  i: show git-flow options
   f: fast-forward this branch from its upstream
   g: view reset options
   R: rename branch
-  ctrl+o: copy branch name to clipboard
   enter: view commits
 
@@ -64,13 +65,13 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   esc: Return to remotes list
   g: view reset options
-  enter: view commits
   space: checkout
   n: new branch
   M: merge into currently checked out branch
   d: delete branch
   r: rebase checked-out branch onto this branch
   u: set as upstream of checked-out branch
+  enter: view commits
 
## Branches Panel (Remotes Tab) @@ -122,12 +123,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Commits Panel (Commits)
-  c: copy commit (cherry-pick)
   ctrl+o: copy commit SHA to clipboard
-  C: copy commit range (cherry-pick)
-  v: paste commits (cherry-pick)
-  n: create new branch off of commit
   ctrl+r: reset cherry-picked (copied) commits selection
+  b: view bisect options
   s: squash down
   f: fixup commit
   r: reword commit
@@ -141,6 +139,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   ctrl+k: move commit up one
   A: amend commit with staged changes
   t: revert commit
+  n: create new branch off of commit
+  c: copy commit (cherry-pick)
+  C: copy commit range (cherry-pick)
+  v: paste commits (cherry-pick)
   ctrl+l: open log menu
   g: reset to this commit
   enter: view commit's files
@@ -148,7 +150,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   T: tag commit
   ctrl+y: copy commit message to clipboard
   o: open commit in browser
-  b: view bisect options
 
## Commits Panel (Reflog Tab) @@ -173,7 +174,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   D: view reset options
-  f: fetch
   ctrl+o: copy the file name to the clipboard
   ctrl+w: Toggle whether or not whitespace changes are shown in the diff view
   space: toggle staged
@@ -191,10 +191,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   S: view stash options
   a: stage/unstage all
   enter: stage individual hunks/lines for file, or collapse/expand for directory
-  :: execute custom command
   g: view upstream reset options
   `: toggle file tree view
   M: open external merge tool (git mergetool)
+  f: fetch
 
## Files Panel (Submodules) diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index b25c18fc5..dde2d47a4 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -21,6 +21,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct @: open command log menu }: Increase the size of the context shown around changes in the diff view {: Decrease the size of the context shown around changes in the diff view + :: voor aangepaste commando uit z: ongedaan maken (via reflog) (experimenteel) ctrl+z: redo (via reflog) (experimenteel) P: push @@ -42,6 +43,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Branches Paneel (Branches Tabblad)
+  i: laat git-flow opties zien
+  ctrl+o: kopieer branch name naar klembord
   space: uitchecken
   o: maak een pull-request
   O: bekijk opties voor pull-aanvraag
@@ -52,11 +55,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   d: verwijder branch
   r: rebase branch
   M: merge in met huidige checked out branch
-  i: laat git-flow opties zien
   f: fast-forward deze branch vanaf zijn upstream
   g: bekijk reset opties
   R: hernoem branch
-  ctrl+o: kopieer branch name naar klembord
   enter: bekijk commits
 
@@ -65,13 +66,13 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   esc: ga terug naar remotes lijst
   g: bekijk reset opties
-  enter: bekijk commits
   space: uitchecken
   n: nieuwe branch
   M: merge in met huidige checked out branch
   d: verwijder branch
   r: rebase branch
   u: stel in als upstream van uitgecheckte branch
+  enter: bekijk commits
 
## Branches Paneel (Remotes Tabblad) @@ -123,12 +124,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Commits Paneel (Commits)
-  c: kopieer commit (cherry-pick)
   ctrl+o: kopieer commit SHA naar klembord
-  C: kopieer commit reeks (cherry-pick)
-  v: plak commits (cherry-pick)
-  n: creëer nieuwe branch van commit
   ctrl+r: reset cherry-picked (gekopieerde) commits selectie
+  b: view bisect options
   s: squash beneden
   f: Fixup commit
   r: hernoem commit
@@ -142,6 +140,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   ctrl+k: verplaats commit 1 naar boven
   A: wijzig commit met staged veranderingen
   t: commit ongedaan maken
+  n: creëer nieuwe branch van commit
+  c: kopieer commit (cherry-pick)
+  C: kopieer commit reeks (cherry-pick)
+  v: plak commits (cherry-pick)
   ctrl+l: open log menu
   g: reset naar deze commit
   enter: bekijk gecommite bestanden
@@ -149,7 +151,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   T: tag commit
   ctrl+y: kopieer commit bericht naar klembord
   o: open commit in browser
-  b: view bisect options
 
## Commits Paneel (Reflog Tabblad) @@ -186,10 +187,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct S: bekijk stash opties a: toggle staged alle enter: stage individuele hunks/lijnen - :: voor aangepaste commando uit g: bekijk upstream reset opties `: toggle bestandsboom weergave M: open external merge tool (git mergetool) + f: fetch ## Bestanden Paneel (Submodules) diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index afc1d3c9c..cb6192968 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -20,6 +20,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct @: open command log menu }: Increase the size of the context shown around changes in the diff view {: Decrease the size of the context shown around changes in the diff view + :: wykonaj własną komendę z: undo (via reflog) (experimental) ctrl+z: redo (via reflog) (experimental) P: push @@ -41,6 +42,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Gałęzie Panel (Branches Tab)
+  i: show git-flow options
+  ctrl+o: copy branch name to clipboard
   space: przełącz
   o: utwórz żądanie pobrania
   O: utwórz opcje żądania ściągnięcia
@@ -51,11 +54,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   d: usuń gałąź
   r: zmiana bazy gałęzi
   M: scal do obecnej gałęzi
-  i: show git-flow options
   f: fast-forward this branch from its upstream
   g: wyświetl opcje resetu
   R: rename branch
-  ctrl+o: copy branch name to clipboard
   enter: view commits
 
@@ -64,13 +65,13 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   esc: wróć do listy repozytoriów zdalnych
   g: wyświetl opcje resetu
-  enter: view commits
   space: przełącz
   n: nowa gałąź
   M: scal do obecnej gałęzi
   d: usuń gałąź
   r: zmiana bazy gałęzi
   u: set as upstream of checked-out branch
+  enter: view commits
 
## Gałęzie Panel (Remotes Tab) @@ -122,12 +123,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## Commity Panel (Commity)
-  c: kopiuj commit (przebieranie)
   ctrl+o: copy commit SHA to clipboard
-  C: kopiuj zakres commitów (przebieranie)
-  v: wklej commity (przebieranie)
-  n: create new branch off of commit
   ctrl+r: reset cherry-picked (copied) commits selection
+  b: view bisect options
   s: ściśnij
   f: napraw commit
   r: zmień nazwę commita
@@ -141,6 +139,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   ctrl+k: przenieś commit 1 w górę
   A: popraw commit zmianami z poczekalni
   t: odwróć commit
+  n: create new branch off of commit
+  c: kopiuj commit (przebieranie)
+  C: kopiuj zakres commitów (przebieranie)
+  v: wklej commity (przebieranie)
   ctrl+l: open log menu
   g: zresetuj do tego commita
   enter: przeglądaj pliki commita
@@ -148,7 +150,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   T: tag commit
   ctrl+y: copy commit message to clipboard
   o: open commit in browser
-  b: view bisect options
 
## Commity Panel (Reflog Tab) @@ -173,7 +174,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   D: wyświetl opcje resetu
-  f: pobierz
   ctrl+o: copy the file name to the clipboard
   ctrl+w: Toggle whether or not whitespace changes are shown in the diff view
   space: przełącz stan poczekalni
@@ -191,10 +191,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   S: wyświetl opcje schowka
   a: przełącz stan poczekalni wszystkich
   enter: zatwierdź pojedyncze linie
-  :: wykonaj własną komendę
   g: view upstream reset options
   `: toggle file tree view
   M: open external merge tool (git mergetool)
+  f: pobierz
 
## Pliki Panel (Submodules) diff --git a/docs/keybindings/Keybindings_zh.md b/docs/keybindings/Keybindings_zh.md index cec585c66..de1915ba1 100644 --- a/docs/keybindings/Keybindings_zh.md +++ b/docs/keybindings/Keybindings_zh.md @@ -20,6 +20,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct @: 打开命令日志菜单 }: Increase the size of the context shown around changes in the diff view {: Decrease the size of the context shown around changes in the diff view + :: 执行自定义命令 z: (通过 reflog)撤销「实验功能」 ctrl+z: (通过 reflog)重做「实验功能」 P: 推送 @@ -41,6 +42,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## 分支 面板 (分支标签)
+  i: 显示 git-flow 选项
+  ctrl+o: 将分支名称复制到剪贴板
   space: 检出
   o: 创建抓取请求
   O: 创建抓取请求选项
@@ -51,11 +54,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   d: 删除分支
   r: 将已检出的分支变基到该分支
   M: 合并到当前检出的分支
-  i: 显示 git-flow 选项
   f: 从上游快进此分支
   g: 查看重置选项
   R: 重命名分支
-  ctrl+o: 将分支名称复制到剪贴板
   enter: 查看提交
 
@@ -64,13 +65,13 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   esc: 返回远程仓库列表
   g: 查看重置选项
-  enter: 查看提交
   space: 检出
   n: 新分支
   M: 合并到当前检出的分支
   d: 删除分支
   r: 将已检出的分支变基到该分支
   u: 设置为检出分支的上游
+  enter: 查看提交
 
## 分支 面板 (远程页面) @@ -122,12 +123,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct ## 提交 面板 (提交)
-  c: 复制提交(拣选)
   ctrl+o: 将提交的 SHA 复制到剪贴板
-  C: 复制提交范围(拣选)
-  v: 粘贴提交(拣选)
-  n: 从提交创建新分支
   ctrl+r: 重置已拣选(复制)的提交
+  b: view bisect options
   s: 向下压缩
   f: 修正提交(fixup)
   r: 改写提交
@@ -141,6 +139,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   ctrl+k: 上移提交
   A: 用已暂存的更改来修补提交
   t: 还原提交
+  n: 从提交创建新分支
+  c: 复制提交(拣选)
+  C: 复制提交范围(拣选)
+  v: 粘贴提交(拣选)
   ctrl+l: open log menu
   g: 重置为此提交
   enter: 查看提交的文件
@@ -148,7 +150,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   T: 标签提交
   ctrl+y: 将提交消息复制到剪贴板
   o: open commit in browser
-  b: view bisect options
 
## 提交 面板 (Reflog) @@ -173,7 +174,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   D: 查看重置选项
-  f: 抓取
   ctrl+o: 将文件名复制到剪贴板
   ctrl+w: 切换是否在差异视图中显示空白更改
   space: 切换暂存状态
@@ -191,10 +191,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
   S: 查看隐藏选项
   a: 切换所有文件的暂存状态
   enter: 暂存单个 块/行 用于文件, 或 折叠/展开 目录
-  :: 执行自定义命令
   g: 查看上游重置选项
   `: 切换文件树视图
   M: 打开合并工具
+  f: 抓取
 
## 文件 面板 (子模块) diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go index f499a2f58..47de22a40 100644 --- a/pkg/cheatsheet/generate.go +++ b/pkg/cheatsheet/generate.go @@ -124,7 +124,7 @@ func formatBinding(binding *types.Binding) string { func getBindingSections(mApp *app.App) []*bindingSection { bindingSections := []*bindingSection{} - bindings, _ := mApp.Gui.GetInitialKeybindings() + bindings := mApp.Gui.GetCheatsheetKeybindings() type contextAndViewType struct { subtitle string diff --git a/pkg/gui/controllers/helpers/helpers.go b/pkg/gui/controllers/helpers/helpers.go index 65f686ade..2ca4fbd40 100644 --- a/pkg/gui/controllers/helpers/helpers.go +++ b/pkg/gui/controllers/helpers/helpers.go @@ -11,3 +11,17 @@ type Helpers struct { CherryPick *CherryPickHelper Host *HostHelper } + +func NewStubHelpers() *Helpers { + return &Helpers{ + Refs: &RefsHelper{}, + Bisect: &BisectHelper{}, + Suggestions: &SuggestionsHelper{}, + Files: &FilesHelper{}, + WorkingTree: &WorkingTreeHelper{}, + Tags: &TagsHelper{}, + MergeAndRebase: &MergeAndRebaseHelper{}, + CherryPick: &CherryPickHelper{}, + Host: &HostHelper{}, + } +} diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 25433eca5..a2dd7a419 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -10,6 +10,7 @@ import ( "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/constants" "github.com/jesseduffield/lazygit/pkg/gui/context" + "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/types" ) @@ -194,6 +195,16 @@ func (gui *Gui) noPopupPanel(f func() error) func() error { } } +// only to be called from the cheatsheet generate script. This mutates the Gui struct. +func (self *Gui) GetCheatsheetKeybindings() []*types.Binding { + self.helpers = helpers.NewStubHelpers() + self.State = &GuiRepoState{} + self.State.Contexts = self.contextTree() + self.resetControllers() + bindings, _ := self.GetInitialKeybindings() + return bindings +} + // renaming receiver to 'self' to aid refactoring. Will probably end up moving all Gui handlers to this pattern eventually. func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBinding) { config := self.c.UserConfig.Keybinding @@ -1306,8 +1317,6 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi func (gui *Gui) resetKeybindings() error { gui.g.DeleteAllKeybindings() - bindings := gui.GetCustomCommandKeybindings() - bindings, mouseBindings := gui.GetInitialKeybindings() // prepending because we want to give our custom keybindings precedence over default keybindings