mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 15:46:26 -04:00
When the config file changes and lazygit regains focus it reloads the config, but the side panel window assignments, default views, tab strips, and z-order were only ever set up on repo entry, so a changed sidePanels wouldn't take effect until restart. Re-apply it from the reload path: reassign windows and default views and restore each panel's default tab. The focused panel needs care: resetting it to its default tab would leave the focused tab hidden behind that default tab, so the panel looks unfocused even though its tab is selected. Re-focus the current context so its tab stays shown and highlighted; only when the new config hides the focused panel entirely do we move focus to the default side panel. Tab strips are already refreshed via configureViewProperties.
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package ui
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
var ReloadSidePanels = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "Editing the side panel config and refocusing the window re-applies the layout live, keeping the focused panel focused",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
SetupConfig: func(cfg *config.AppConfig) {},
|
|
SetupRepo: func(shell *Shell) {
|
|
shell.CreateNCommits(2)
|
|
// Start with worktrees promoted to its own panel.
|
|
shell.CreateFile(".git/lazygit.yml", `
|
|
gui:
|
|
sidePanels:
|
|
- [status]
|
|
- [files, submodules]
|
|
- [worktrees]
|
|
- [branches, remotes, tags]
|
|
- [commits, reflog]
|
|
- [stash]`)
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
// Worktrees is its own panel in the third position.
|
|
t.Views().Files().IsFocused().
|
|
Press(keys.Universal.JumpToBlock[2])
|
|
t.Views().Worktrees().IsFocused()
|
|
|
|
// Demote worktrees back into the files panel, then refocus the window to
|
|
// trigger a live reload of the changed config.
|
|
t.Shell().UpdateFile(".git/lazygit.yml", `
|
|
gui:
|
|
sidePanels:
|
|
- [status]
|
|
- [files, worktrees, submodules]
|
|
- [branches, remotes, tags]
|
|
- [commits, reflog]
|
|
- [stash]`)
|
|
t.FocusIn()
|
|
|
|
// Worktrees is now a tab of the files panel. It stays focused, and is shown
|
|
// in front rather than being hidden behind the files tab (which would leave
|
|
// the panel looking unfocused).
|
|
t.Views().Worktrees().IsActiveTab().IsFocused().
|
|
Press(keys.Universal.PrevTab)
|
|
t.Views().Files().IsActiveTab().IsFocused()
|
|
},
|
|
})
|