1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-10-19 08:09:21 +03:00

Add config option gui.skipSwitchWorktreeOnCheckoutWarning

This commit is contained in:
Stefan Haller
2025-10-14 14:03:58 +02:00
parent d3fb22a673
commit 80f860beb7
4 changed files with 39 additions and 29 deletions

View File

@@ -91,6 +91,10 @@ gui:
# If true, do not show a warning when rewording a commit via an external editor # If true, do not show a warning when rewording a commit via an external editor
skipRewordInEditorWarning: false skipRewordInEditorWarning: false
# If true, switch to a different worktree without confirmation when checking out
# a branch that is checked out in that worktree
skipSwitchWorktreeOnCheckoutWarning: false
# Fraction of the total screen width to use for the left side section. You may # Fraction of the total screen width to use for the left side section. You may
# want to pick a small number (e.g. 0.2) if you're using a narrow screen, so # want to pick a small number (e.g. 0.2) if you're using a narrow screen, so
# that you can see more of the main section. # that you can see more of the main section.

View File

@@ -84,6 +84,8 @@ type GuiConfig struct {
SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"` SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
// If true, do not show a warning when rewording a commit via an external editor // If true, do not show a warning when rewording a commit via an external editor
SkipRewordInEditorWarning bool `yaml:"skipRewordInEditorWarning"` SkipRewordInEditorWarning bool `yaml:"skipRewordInEditorWarning"`
// If true, switch to a different worktree without confirmation when checking out a branch that is checked out in that worktree
SkipSwitchWorktreeOnCheckoutWarning bool `yaml:"skipSwitchWorktreeOnCheckoutWarning"`
// Fraction of the total screen width to use for the left side section. You may want to pick a small number (e.g. 0.2) if you're using a narrow screen, so that you can see more of the main section. // Fraction of the total screen width to use for the left side section. You may want to pick a small number (e.g. 0.2) if you're using a narrow screen, so that you can see more of the main section.
// Number from 0 to 1.0. // Number from 0 to 1.0.
SidePanelWidth float64 `yaml:"sidePanelWidth" jsonschema:"maximum=1,minimum=0"` SidePanelWidth float64 `yaml:"sidePanelWidth" jsonschema:"maximum=1,minimum=0"`
@@ -793,6 +795,7 @@ func GetDefaultConfig() *UserConfig {
CommandLogSize: 8, CommandLogSize: 8,
SplitDiff: "auto", SplitDiff: "auto",
SkipRewordInEditorWarning: false, SkipRewordInEditorWarning: false,
SkipSwitchWorktreeOnCheckoutWarning: false,
ScreenMode: "normal", ScreenMode: "normal",
Border: "rounded", Border: "rounded",
AnimateExplosion: true, AnimateExplosion: true,

View File

@@ -420,15 +420,13 @@ func (self *BranchesController) promptToCheckoutWorktree(worktree *models.Worktr
"worktreeName": worktree.Name, "worktreeName": worktree.Name,
}) })
self.c.Confirm(types.ConfirmOpts{ return self.c.ConfirmIf(!self.c.UserConfig().Gui.SkipSwitchWorktreeOnCheckoutWarning, types.ConfirmOpts{
Title: self.c.Tr.SwitchToWorktree, Title: self.c.Tr.SwitchToWorktree,
Prompt: prompt, Prompt: prompt,
HandleConfirm: func() error { HandleConfirm: func() error {
return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY) return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY)
}, },
}) })
return nil
} }
func (self *BranchesController) handleCreatePullRequest(selectedBranch *models.Branch) error { func (self *BranchesController) handleCreatePullRequest(selectedBranch *models.Branch) error {

View File

@@ -532,6 +532,11 @@
"description": "If true, do not show a warning when rewording a commit via an external editor", "description": "If true, do not show a warning when rewording a commit via an external editor",
"default": false "default": false
}, },
"skipSwitchWorktreeOnCheckoutWarning": {
"type": "boolean",
"description": "If true, switch to a different worktree without confirmation when checking out a branch that is checked out in that worktree",
"default": false
},
"sidePanelWidth": { "sidePanelWidth": {
"type": "number", "type": "number",
"maximum": 1, "maximum": 1,