diff --git a/docs/Config.md b/docs/Config.md index c81d1dc0143..432e701863e 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -246,6 +246,12 @@ gui: # One of 'dashboard' (default) | 'allBranchesLog' statusPanelView: dashboard + # If true, jump to the Files panel after popping a stash + switchToFilesAfterStashPop: true + + # If true, jump to the Files panel after applying a stash + switchToFilesAfterStashApply: true + # Config relating to git git: # See https://github.com/jesseduffield/lazygit/blob/master/docs/Custom_Pagers.md diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index e11e5b6c2da..2a8778ef9db 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -161,6 +161,10 @@ type GuiConfig struct { // Status panel view. // One of 'dashboard' (default) | 'allBranchesLog' StatusPanelView string `yaml:"statusPanelView" jsonschema:"enum=dashboard,enum=allBranchesLog"` + // If true, jump to the Files panel after popping a stash + SwitchToFilesAfterStashPop bool `yaml:"switchToFilesAfterStashPop"` + // If true, jump to the Files panel after applying a stash + SwitchToFilesAfterStashApply bool `yaml:"switchToFilesAfterStashApply"` } func (c *GuiConfig) UseFuzzySearch() bool { @@ -729,7 +733,9 @@ func GetDefaultConfig() *UserConfig { Frames: []string{"|", "/", "-", "\\"}, Rate: 50, }, - StatusPanelView: "dashboard", + StatusPanelView: "dashboard", + SwitchToFilesAfterStashPop: true, + SwitchToFilesAfterStashApply: true, }, Git: GitConfig{ Paging: PagingConfig{ diff --git a/pkg/gui/controllers/stash_controller.go b/pkg/gui/controllers/stash_controller.go index 808376c53b4..bc0721b8757 100644 --- a/pkg/gui/controllers/stash_controller.go +++ b/pkg/gui/controllers/stash_controller.go @@ -111,7 +111,9 @@ func (self *StashController) handleStashApply(stashEntry *models.StashEntry) err if err != nil { return err } - self.c.Context().Push(self.c.Contexts().Files) + if self.c.UserConfig().Gui.SwitchToFilesAfterStashApply { + self.c.Context().Push(self.c.Contexts().Files) + } return nil } @@ -138,7 +140,9 @@ func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error if err != nil { return err } - self.c.Context().Push(self.c.Contexts().Files) + if self.c.UserConfig().Gui.SwitchToFilesAfterStashPop { + self.c.Context().Push(self.c.Contexts().Files) + } return nil } diff --git a/schema/config.json b/schema/config.json index dc5db6f5860..78e932f9d3e 100644 --- a/schema/config.json +++ b/schema/config.json @@ -452,6 +452,16 @@ ], "description": "Status panel view.\nOne of 'dashboard' (default) | 'allBranchesLog'", "default": "dashboard" + }, + "switchToFilesAfterStashPop": { + "type": "boolean", + "description": "If true, jump to the Files panel after popping a stash", + "default": true + }, + "switchToFilesAfterStashApply": { + "type": "boolean", + "description": "If true, jump to the Files panel after applying a stash", + "default": true } }, "additionalProperties": false,