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"`
@@ -772,32 +774,33 @@ func GetDefaultConfig() *UserConfig {
UnstagedChangesColor: []string{"red"}, UnstagedChangesColor: []string{"red"},
DefaultFgColor: []string{"default"}, DefaultFgColor: []string{"default"},
}, },
CommitLength: CommitLengthConfig{Show: true}, CommitLength: CommitLengthConfig{Show: true},
SkipNoStagedFilesWarning: false, SkipNoStagedFilesWarning: false,
ShowListFooter: true, ShowListFooter: true,
ShowCommandLog: true, ShowCommandLog: true,
ShowBottomLine: true, ShowBottomLine: true,
ShowPanelJumps: true, ShowPanelJumps: true,
ShowFileTree: true, ShowFileTree: true,
ShowRootItemInFileTree: true, ShowRootItemInFileTree: true,
ShowNumstatInFilesView: false, ShowNumstatInFilesView: false,
ShowRandomTip: true, ShowRandomTip: true,
ShowIcons: false, ShowIcons: false,
NerdFontsVersion: "", NerdFontsVersion: "",
ShowFileIcons: true, ShowFileIcons: true,
CommitAuthorShortLength: 2, CommitAuthorShortLength: 2,
CommitAuthorLongLength: 17, CommitAuthorLongLength: 17,
CommitHashLength: 8, CommitHashLength: 8,
ShowBranchCommitHash: false, ShowBranchCommitHash: false,
ShowDivergenceFromBaseBranch: "none", ShowDivergenceFromBaseBranch: "none",
CommandLogSize: 8, CommandLogSize: 8,
SplitDiff: "auto", SplitDiff: "auto",
SkipRewordInEditorWarning: false, SkipRewordInEditorWarning: false,
ScreenMode: "normal", SkipSwitchWorktreeOnCheckoutWarning: false,
Border: "rounded", ScreenMode: "normal",
AnimateExplosion: true, Border: "rounded",
PortraitMode: "auto", AnimateExplosion: true,
FilterMode: "substring", PortraitMode: "auto",
FilterMode: "substring",
Spinner: SpinnerConfig{ Spinner: SpinnerConfig{
Frames: []string{"|", "/", "-", "\\"}, Frames: []string{"|", "/", "-", "\\"},
Rate: 50, Rate: 50,

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,