Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for disabling switching to the Files panel after popping or applying a stash #3913

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -729,7 +733,9 @@ func GetDefaultConfig() *UserConfig {
Frames: []string{"|", "/", "-", "\\"},
Rate: 50,
},
StatusPanelView: "dashboard",
StatusPanelView: "dashboard",
SwitchToFilesAfterStashPop: true,
SwitchToFilesAfterStashApply: true,
},
Git: GitConfig{
Paging: PagingConfig{
Expand Down
8 changes: 6 additions & 2 deletions pkg/gui/controllers/stash_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
10 changes: 10 additions & 0 deletions schema/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading