diff --git a/docs-master/keybindings/Keybindings_en.md b/docs-master/keybindings/Keybindings_en.md index ca1541dd21d..07dd1cecda1 100644 --- a/docs-master/keybindings/Keybindings_en.md +++ b/docs-master/keybindings/Keybindings_en.md @@ -14,6 +14,11 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` @ `` | View command log options | View options for the command log e.g. show/hide the command log and focus the command log. | | `` P `` | Push | Push the current branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull | Pull changes from the remote for the current branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | Increase rename similarity threshold | Increase the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` ( `` | Decrease rename similarity threshold | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` } `` | Increase diff context size | Increase the amount of the context shown around changes in the diff view.

The default can be changed in the config file with the key 'git.diffContextSize'. | diff --git a/docs-master/keybindings/Keybindings_ja.md b/docs-master/keybindings/Keybindings_ja.md index 69479db13e7..89742afa75c 100644 --- a/docs-master/keybindings/Keybindings_ja.md +++ b/docs-master/keybindings/Keybindings_ja.md @@ -14,6 +14,11 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味 | `` @ `` | コマンドログオプションを表示 | コマンドログのオプションを表示します(例:コマンドログの表示/非表示、コマンドログへのフォーカスなど)。 | | `` P `` | プッシュ | 現在のブランチを対応するアップストリームブランチにプッシュします。アップストリームが設定されていない場合、アップストリームブランチの設定を求められます。 | | `` p `` | プル | 現在のブランチのリモートから変更をプルします。アップストリームが設定されていない場合、アップストリームブランチの設定を求められます。 | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | リネーム検出の類似度しきい値を上げる | Increase the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` ( `` | リネーム検出の類似度しきい値を下げる | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` } `` | 差分コンテキストサイズを増やす | Increase the amount of the context shown around changes in the diff view.

The default can be changed in the config file with the key 'git.diffContextSize'. | diff --git a/docs-master/keybindings/Keybindings_ko.md b/docs-master/keybindings/Keybindings_ko.md index eeb5ed88510..b76d54ec425 100644 --- a/docs-master/keybindings/Keybindings_ko.md +++ b/docs-master/keybindings/Keybindings_ko.md @@ -14,6 +14,11 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` @ `` | 명령어 로그 메뉴 열기 | View options for the command log e.g. show/hide the command log and focus the command log. | | `` P `` | 푸시 | Push the current branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | 업데이트 | Pull changes from the remote for the current branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | Increase rename similarity threshold | Increase the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` ( `` | Decrease rename similarity threshold | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` } `` | Diff 보기의 변경 사항 주위에 표시되는 컨텍스트의 크기를 늘리기 | Increase the amount of the context shown around changes in the diff view.

The default can be changed in the config file with the key 'git.diffContextSize'. | diff --git a/docs-master/keybindings/Keybindings_nl.md b/docs-master/keybindings/Keybindings_nl.md index 21b8c5b4c60..d9c39baacb4 100644 --- a/docs-master/keybindings/Keybindings_nl.md +++ b/docs-master/keybindings/Keybindings_nl.md @@ -14,6 +14,11 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` @ `` | View command log options | View options for the command log e.g. show/hide the command log and focus the command log. | | `` P `` | Push | Push the current branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull | Pull changes from the remote for the current branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | Increase rename similarity threshold | Increase the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` ( `` | Decrease rename similarity threshold | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` } `` | Increase diff context size | Increase the amount of the context shown around changes in the diff view.

The default can be changed in the config file with the key 'git.diffContextSize'. | diff --git a/docs-master/keybindings/Keybindings_pl.md b/docs-master/keybindings/Keybindings_pl.md index 622a134fd53..ee0f7bc2cd2 100644 --- a/docs-master/keybindings/Keybindings_pl.md +++ b/docs-master/keybindings/Keybindings_pl.md @@ -14,6 +14,11 @@ _Legenda: `` oznacza ctrl+b, `` oznacza alt+b, `B` oznacza shift+b_ | `` @ `` | Pokaż opcje dziennika poleceń | Pokaż opcje dla dziennika poleceń, np. pokazywanie/ukrywanie dziennika poleceń i skupienie na dzienniku poleceń. | | `` P `` | Wypchnij | Wypchnij bieżącą gałąź do jej gałęzi nadrzędnej. Jeśli nie skonfigurowano gałęzi nadrzędnej, zostaniesz poproszony o skonfigurowanie gałęzi nadrzędnej. | | `` p `` | Pociągnij | Pociągnij zmiany z zdalnego dla bieżącej gałęzi. Jeśli nie skonfigurowano gałęzi nadrzędnej, zostaniesz poproszony o skonfigurowanie gałęzi nadrzędnej. | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | Increase rename similarity threshold | Increase the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` ( `` | Decrease rename similarity threshold | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` } `` | Zwiększ rozmiar kontekstu w widoku różnic | Increase the amount of the context shown around changes in the diff view.

The default can be changed in the config file with the key 'git.diffContextSize'. | diff --git a/docs-master/keybindings/Keybindings_pt.md b/docs-master/keybindings/Keybindings_pt.md index 81dc4085e5f..0300369b950 100644 --- a/docs-master/keybindings/Keybindings_pt.md +++ b/docs-master/keybindings/Keybindings_pt.md @@ -14,6 +14,11 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` @ `` | View command log options | View options for the command log e.g. show/hide the command log and focus the command log. | | `` P `` | Empurre (Push) | Faça push do branch atual para o seu branch upstream. Se nenhum upstream estiver configurado, você será solicitado a configurar um branch a montante. | | `` p `` | Puxar (Pull) | Puxe alterações do controle remoto para o ramo atual. Se nenhum upstream estiver configurado, será solicitado configurar um ramo a montante. | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | Increase rename similarity threshold | Increase the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` ( `` | Decrease rename similarity threshold | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` } `` | Increase diff context size | Increase the amount of the context shown around changes in the diff view.

The default can be changed in the config file with the key 'git.diffContextSize'. | diff --git a/docs-master/keybindings/Keybindings_ru.md b/docs-master/keybindings/Keybindings_ru.md index b4531eb7305..eb0ffc4721f 100644 --- a/docs-master/keybindings/Keybindings_ru.md +++ b/docs-master/keybindings/Keybindings_ru.md @@ -14,6 +14,11 @@ _Связки клавиш_ | `` @ `` | Открыть меню журнала команд | View options for the command log e.g. show/hide the command log and focus the command log. | | `` P `` | Отправить изменения | Push the current branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Получить и слить изменения | Pull changes from the remote for the current branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | Increase rename similarity threshold | Increase the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` ( `` | Decrease rename similarity threshold | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` } `` | Увеличить размер контекста, отображаемого вокруг изменений в просмотрщике сравнении | Increase the amount of the context shown around changes in the diff view.

The default can be changed in the config file with the key 'git.diffContextSize'. | diff --git a/docs-master/keybindings/Keybindings_zh-CN.md b/docs-master/keybindings/Keybindings_zh-CN.md index 0385e486b5c..09e09196103 100644 --- a/docs-master/keybindings/Keybindings_zh-CN.md +++ b/docs-master/keybindings/Keybindings_zh-CN.md @@ -14,6 +14,11 @@ _图例:`` 意味着ctrl+b, `意味着Alt+b, `B` 意味着shift+b_ | `` @ `` | 打开命令日志菜单 | 查看命令日志的选项,例如显示/隐藏命令日志以及聚焦命令日志 | | `` P `` | 推送 | 推送当前分支到它的上游。如果上游未配置,您可以在弹窗中配置上游分支。 | | `` p `` | 拉取 | 从当前分支的远程分支获取改动。如果上游未配置,您可以在弹窗中配置上游分支。 | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | 提高重命名相似度阈值 | 提高将删除和添加对视为重命名所需的相似度阈值。

默认值可在配置文件中通过键 'git.renameSimilarityThreshold' 更改。 | | `` ( `` | 降低重命名相似度阈值 | 降低将删除和添加对视为重命名所需的相似度阈值。

默认值可在配置文件中通过键 'git.renameSimilarityThreshold' 更改。 | | `` } `` | 扩大差异视图中显示的上下文范围 | 增加差异视图中变更周围显示的上下文量。

默认值可在配置文件中通过键 'git.diffContextSize' 更改。 | diff --git a/docs-master/keybindings/Keybindings_zh-TW.md b/docs-master/keybindings/Keybindings_zh-TW.md index c0579e0ced8..beb1c147d39 100644 --- a/docs-master/keybindings/Keybindings_zh-TW.md +++ b/docs-master/keybindings/Keybindings_zh-TW.md @@ -14,6 +14,11 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B | `` @ `` | 開啟命令記錄選單 | View options for the command log e.g. show/hide the command log and focus the command log. | | `` P `` | 推送 | 推送到遠端。如果沒有設定遠端,會開啟設定視窗。 | | `` p `` | 拉取 | 從遠端同步當前分支。如果沒有設定遠端,會開啟設定視窗。 | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | Increase rename similarity threshold | Increase the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` ( `` | Decrease rename similarity threshold | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` } `` | 增加差異檢視中顯示變更周圍上下文的大小 | Increase the amount of the context shown around changes in the diff view.

The default can be changed in the config file with the key 'git.diffContextSize'. | diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index ca1541dd21d..07dd1cecda1 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -14,6 +14,11 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` @ `` | View command log options | View options for the command log e.g. show/hide the command log and focus the command log. | | `` P `` | Push | Push the current branch to its upstream branch. If no upstream is configured, you will be prompted to configure an upstream branch. | | `` p `` | Pull | Pull changes from the remote for the current branch. If no upstream is configured, you will be prompted to configure an upstream branch. | +| `` 1 `` | Jump to side panel | | +| `` 2 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 3 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 4 `` | Collapse/expand side panel | When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts. | +| `` 5 `` | Jump to side panel | | | `` ) `` | Increase rename similarity threshold | Increase the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` ( `` | Decrease rename similarity threshold | Decrease the similarity threshold for a deletion and addition pair to be treated as a rename.

The default can be changed in the config file with the key 'git.renameSimilarityThreshold'. | | `` } `` | Increase diff context size | Increase the amount of the context shown around changes in the diff view.

The default can be changed in the config file with the key 'git.diffContextSize'. | diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 038d6c11785..a078932f80e 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -708,6 +708,9 @@ type AppState struct { // Cache of GitHub pull requests per repo path, so that PR info can be // shown instantly on startup before the async refresh completes. GithubPullRequests map[string][]CachedPullRequest `yaml:"githubPullRequests"` + + // Side windows that the user has manually collapsed (files, branches, commits). + CollapsedSideWindows []string } // CachedPullRequest stores the essential fields of a GitHub pull request diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper.go b/pkg/gui/controllers/helpers/window_arrangement_helper.go index 9061d517729..9274e1ad574 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper.go @@ -10,6 +10,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" + "github.com/samber/lo" "golang.org/x/exp/slices" ) @@ -72,6 +73,8 @@ type WindowArrangementArgs struct { InSearchPrompt bool // One of '' (not searching), 'Search: ', and 'Filter: ' SearchPrefix string + // Side windows that the user has manually collapsed + CollapsedSideWindows []string } func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, appStatus string) map[string]boxlayout.Dimensions { @@ -86,20 +89,21 @@ func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, } args := WindowArrangementArgs{ - Width: width, - Height: height, - UserConfig: self.c.UserConfig(), - CurrentWindow: self.c.Context().CurrentStatic().GetWindowName(), - CurrentSideWindow: self.c.Context().CurrentSide().GetWindowName(), - SplitMainPanel: repoState.GetSplitMainPanel(), - ScreenMode: repoState.GetScreenMode(), - AppStatus: appStatus, - InformationStr: informationStr, - ShowExtrasWindow: self.c.State().GetShowExtrasWindow(), - InDemo: self.c.InDemo(), - IsAnyModeActive: self.modeHelper.IsAnyModeActive(), - InSearchPrompt: repoState.InSearchPrompt(), - SearchPrefix: searchPrefix, + Width: width, + Height: height, + UserConfig: self.c.UserConfig(), + CurrentWindow: self.c.Context().CurrentStatic().GetWindowName(), + CurrentSideWindow: self.c.Context().CurrentSide().GetWindowName(), + SplitMainPanel: repoState.GetSplitMainPanel(), + ScreenMode: repoState.GetScreenMode(), + AppStatus: appStatus, + InformationStr: informationStr, + ShowExtrasWindow: self.c.State().GetShowExtrasWindow(), + InDemo: self.c.InDemo(), + IsAnyModeActive: self.modeHelper.IsAnyModeActive(), + InSearchPrompt: repoState.InSearchPrompt(), + SearchPrefix: searchPrefix, + CollapsedSideWindows: self.c.GetAppState().CollapsedSideWindows, } return GetWindowDimensions(args) @@ -420,6 +424,10 @@ func getDefaultStashWindowBox(args WindowArrangementArgs) *boxlayout.Box { } func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) []*boxlayout.Box { + isCollapsed := func(window string) bool { + return slices.Contains(args.CollapsedSideWindows, window) + } + return func(width int, height int) []*boxlayout.Box { if args.ScreenMode == types.SCREEN_FULL || args.ScreenMode == types.SCREEN_HALF { fullHeightBox := func(window string) *boxlayout.Box { @@ -446,6 +454,9 @@ func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) [ } else if height >= 28 { accordionMode := args.UserConfig.Gui.ExpandFocusedSidePanel accordionBox := func(defaultBox *boxlayout.Box) *boxlayout.Box { + if isCollapsed(defaultBox.Window) { + return &boxlayout.Box{Window: defaultBox.Window, Size: 3} + } if accordionMode && defaultBox.Window == args.CurrentSideWindow { return &boxlayout.Box{ Window: defaultBox.Window, @@ -456,7 +467,7 @@ func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) [ return defaultBox } - return []*boxlayout.Box{ + boxes := []*boxlayout.Box{ { Window: "status", Size: 3, @@ -466,6 +477,13 @@ func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) [ accordionBox(&boxlayout.Box{Window: "commits", Weight: 1}), accordionBox(getDefaultStashWindowBox(args)), } + // If all panels ended up with a fixed size (e.g. all collapsible + // panels are collapsed), give stash a weight so the remaining + // space is allocated and boxlayout doesn't panic. + if !lo.SomeBy(boxes, func(b *boxlayout.Box) bool { return b.Weight > 0 }) { + boxes[4] = &boxlayout.Box{Window: "stash", Weight: 1} + } + return boxes } squashedHeight := 1 @@ -474,6 +492,9 @@ func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) [ } squashedSidePanelBox := func(window string) *boxlayout.Box { + if isCollapsed(window) { + return &boxlayout.Box{Window: window, Size: 3} + } if window == args.CurrentSideWindow { return &boxlayout.Box{ Window: window, @@ -487,12 +508,16 @@ func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) [ } } - return []*boxlayout.Box{ + boxes := []*boxlayout.Box{ squashedSidePanelBox("status"), squashedSidePanelBox("files"), squashedSidePanelBox("branches"), squashedSidePanelBox("commits"), squashedSidePanelBox("stash"), } + if !lo.SomeBy(boxes, func(b *boxlayout.Box) bool { return b.Weight > 0 }) { + boxes[4] = &boxlayout.Box{Window: "stash", Weight: 1} + } + return boxes } } diff --git a/pkg/gui/controllers/jump_to_side_window_controller.go b/pkg/gui/controllers/jump_to_side_window_controller.go index c0ef2faece3..e32aadfc09d 100644 --- a/pkg/gui/controllers/jump_to_side_window_controller.go +++ b/pkg/gui/controllers/jump_to_side_window_controller.go @@ -6,6 +6,7 @@ import ( "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" + "golang.org/x/exp/slices" ) type JumpToSideWindowController struct { @@ -37,8 +38,16 @@ func (self *JumpToSideWindowController) GetKeybindings(opts types.KeybindingsOpt } return lo.Map(windows, func(window string, index int) *types.Binding { + description := self.c.Tr.JumpToSidePanel + tooltip := "" + if slices.Contains(collapsibleSideWindows, window) { + description = self.c.Tr.CollapseSidePanel + tooltip = "When the panel is already focused, pressing the key again collapses it to a minimal size. Pressing it once more uncollapses it. The collapsed state is persisted across restarts." + } return &types.Binding{ - ViewName: "", + ViewName: "", + Description: description, + Tooltip: tooltip, // by default the keys are 1, 2, 3, etc Key: opts.GetKey(opts.Config.Universal.JumpToBlock[index]), Modifier: gocui.ModNone, @@ -47,15 +56,47 @@ func (self *JumpToSideWindowController) GetKeybindings(opts types.KeybindingsOpt }) } +// collapsibleSideWindows are the side windows that can be collapsed by pressing +// their number key a second time. Status (1) and stash (5) are excluded. +var collapsibleSideWindows = []string{"files", "branches", "commits"} + func (self *JumpToSideWindowController) goToSideWindow(window string) func() error { return func() error { + appState := self.c.GetAppState() + isCollapsible := slices.Contains(collapsibleSideWindows, window) + isCollapsed := slices.Contains(appState.CollapsedSideWindows, window) + + if isCollapsed { + // Uncollapse and navigate to the window + appState.CollapsedSideWindows = lo.Filter(appState.CollapsedSideWindows, func(w string, _ int) bool { + return w != window + }) + self.c.SaveAppStateAndLogError() + } + sideWindowAlreadyActive := self.c.Helpers().Window.CurrentWindow() == window + if sideWindowAlreadyActive && isCollapsible && !isCollapsed { + // Second press on the active window: collapse it and move focus away + appState.CollapsedSideWindows = append(appState.CollapsedSideWindows, window) + self.c.SaveAppStateAndLogError() + + // Navigate to the nearest non-collapsed side window + allSideWindows := self.c.Helpers().Window.SideWindows() + for _, candidate := range allSideWindows { + if candidate != window && !slices.Contains(appState.CollapsedSideWindows, candidate) { + context := self.c.Helpers().Window.GetContextForWindow(candidate) + self.c.Context().Push(context, types.OnFocusOpts{}) + break + } + } + return nil + } + if sideWindowAlreadyActive && self.c.UserConfig().Gui.SwitchTabsWithPanelJumpKeys { return self.nextTabFunc() } context := self.c.Helpers().Window.GetContextForWindow(window) - self.c.Context().Push(context, types.OnFocusOpts{}) return nil } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 002adb11410..be474ac4490 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -265,6 +265,8 @@ type TranslationSet struct { ExcludeFile string RefreshFiles string FocusMainView string + JumpToSidePanel string + CollapseSidePanel string Merge string MergeBranchTooltip string RegularMergeFastForward string @@ -1384,6 +1386,8 @@ func EnglishTranslationSet() *TranslationSet { ExcludeFile: `Add to .git/info/exclude`, RefreshFiles: `Refresh files`, FocusMainView: "Focus main view", + JumpToSidePanel: "Jump to side panel", + CollapseSidePanel: "Collapse/expand side panel", Merge: `Merge`, MergeBranchTooltip: "View options for merging the selected item into the current branch (regular merge, squash merge)", RegularMergeFastForward: "Regular merge (fast-forward)", diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 04c12e60047..6b9030a2d53 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -462,6 +462,8 @@ var tests = []*components.IntegrationTest{ tag.Reset, tag.ResetToDuplicateNamedBranch, ui.Accordion, + ui.CollapseSidePanel, + ui.CollapseSidePanelSticky, ui.DisableSwitchTabWithPanelJumpKeys, ui.EmptyMenu, ui.KeybindingSuggestionsWhenSwitchingRepos, diff --git a/pkg/integration/tests/ui/collapse_side_panel.go b/pkg/integration/tests/ui/collapse_side_panel.go new file mode 100644 index 00000000000..76582e77f83 --- /dev/null +++ b/pkg/integration/tests/ui/collapse_side_panel.go @@ -0,0 +1,48 @@ +package ui + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CollapseSidePanel = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Pressing a panel's number key a second time collapses it; pressing it again uncollapses it", + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateNCommits(3) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + // Start with files focused (default) + t.Views().Files().IsFocused() + + // Press "2" again to collapse the files panel; focus should move away + t.Views().Files().Press(keys.Universal.JumpToBlock[1]) + t.Views().Status().IsFocused() + + // Press "2" again to uncollapse files and focus it + t.Views().Status().Press(keys.Universal.JumpToBlock[1]) + t.Views().Files().IsFocused() + + // Navigate to branches panel + t.Views().Branches().Focus() + + // Press "3" again to collapse branches; focus should move away + t.Views().Branches().Press(keys.Universal.JumpToBlock[2]) + t.Views().Status().IsFocused() + + // Press "3" again to uncollapse branches and focus it + t.Views().Status().Press(keys.Universal.JumpToBlock[2]) + t.Views().Branches().IsFocused() + + // Navigate to commits panel + t.Views().Commits().Focus() + + // Press "4" again to collapse commits; focus should move away + t.Views().Commits().Press(keys.Universal.JumpToBlock[3]) + t.Views().Status().IsFocused() + + // When files is collapsed and we jump to it, it uncollapses + t.Views().Files().Focus() + t.Views().Files().IsFocused() + }, +}) diff --git a/pkg/integration/tests/ui/collapse_side_panel_sticky.go b/pkg/integration/tests/ui/collapse_side_panel_sticky.go new file mode 100644 index 00000000000..f53a3154eb2 --- /dev/null +++ b/pkg/integration/tests/ui/collapse_side_panel_sticky.go @@ -0,0 +1,43 @@ +package ui + +import ( + "os" + "path/filepath" + + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CollapseSidePanelSticky = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Collapsing a side panel is persisted to state.yml so it survives restarts", + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateNCommits(3) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + stateFile := filepath.Join(os.Getenv("CONFIG_DIR"), "state.yml") + + // Collapse files (pane 2) + t.Views().Files().IsFocused() + t.Views().Files().Press(keys.Universal.JumpToBlock[1]) + t.Views().Status().IsFocused() + + // State file should now record "files" as collapsed + t.FileSystem().FileContent(stateFile, Contains("collapsedsidewindows")) + t.FileSystem().FileContent(stateFile, Contains("- files")) + + // Collapse branches (pane 3) too + t.Views().Branches().Focus() + t.Views().Branches().Press(keys.Universal.JumpToBlock[2]) + t.Views().Status().IsFocused() + + t.FileSystem().FileContent(stateFile, Contains("- branches")) + + // Uncollapsing should remove the entry from state.yml + t.Views().Status().Press(keys.Universal.JumpToBlock[1]) + t.Views().Files().IsFocused() + + t.FileSystem().FileContent(stateFile, DoesNotContain("- files")) + t.FileSystem().FileContent(stateFile, Contains("- branches")) + }, +})