Skip to content

Commit 9ab7054

Browse files
committed
Add config option gui.skipSwitchWorktreeOnCheckoutWarning
1 parent d3fb22a commit 9ab7054

File tree

4 files changed

+39
-27
lines changed

4 files changed

+39
-27
lines changed

docs/Config.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ gui:
9191
# If true, do not show a warning when rewording a commit via an external editor
9292
skipRewordInEditorWarning: false
9393

94+
# If true, switch to a different worktree without confirmation when checking out
95+
# a branch that is checked out in that worktree
96+
skipSwitchWorktreeOnCheckoutWarning: false
97+
9498
# Fraction of the total screen width to use for the left side section. You may
9599
# want to pick a small number (e.g. 0.2) if you're using a narrow screen, so
96100
# that you can see more of the main section.

pkg/config/user_config.go

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ type GuiConfig struct {
8484
SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
8585
// If true, do not show a warning when rewording a commit via an external editor
8686
SkipRewordInEditorWarning bool `yaml:"skipRewordInEditorWarning"`
87+
// If true, switch to a different worktree without confirmation when checking out a branch that is checked out in that worktree
88+
SkipSwitchWorktreeOnCheckoutWarning bool `yaml:"skipSwitchWorktreeOnCheckoutWarning"`
8789
// 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.
8890
// Number from 0 to 1.0.
8991
SidePanelWidth float64 `yaml:"sidePanelWidth" jsonschema:"maximum=1,minimum=0"`
@@ -772,32 +774,33 @@ func GetDefaultConfig() *UserConfig {
772774
UnstagedChangesColor: []string{"red"},
773775
DefaultFgColor: []string{"default"},
774776
},
775-
CommitLength: CommitLengthConfig{Show: true},
776-
SkipNoStagedFilesWarning: false,
777-
ShowListFooter: true,
778-
ShowCommandLog: true,
779-
ShowBottomLine: true,
780-
ShowPanelJumps: true,
781-
ShowFileTree: true,
782-
ShowRootItemInFileTree: true,
783-
ShowNumstatInFilesView: false,
784-
ShowRandomTip: true,
785-
ShowIcons: false,
786-
NerdFontsVersion: "",
787-
ShowFileIcons: true,
788-
CommitAuthorShortLength: 2,
789-
CommitAuthorLongLength: 17,
790-
CommitHashLength: 8,
791-
ShowBranchCommitHash: false,
792-
ShowDivergenceFromBaseBranch: "none",
793-
CommandLogSize: 8,
794-
SplitDiff: "auto",
795-
SkipRewordInEditorWarning: false,
796-
ScreenMode: "normal",
797-
Border: "rounded",
798-
AnimateExplosion: true,
799-
PortraitMode: "auto",
800-
FilterMode: "substring",
777+
CommitLength: CommitLengthConfig{Show: true},
778+
SkipNoStagedFilesWarning: false,
779+
ShowListFooter: true,
780+
ShowCommandLog: true,
781+
ShowBottomLine: true,
782+
ShowPanelJumps: true,
783+
ShowFileTree: true,
784+
ShowRootItemInFileTree: true,
785+
ShowNumstatInFilesView: false,
786+
ShowRandomTip: true,
787+
ShowIcons: false,
788+
NerdFontsVersion: "",
789+
ShowFileIcons: true,
790+
CommitAuthorShortLength: 2,
791+
CommitAuthorLongLength: 17,
792+
CommitHashLength: 8,
793+
ShowBranchCommitHash: false,
794+
ShowDivergenceFromBaseBranch: "none",
795+
CommandLogSize: 8,
796+
SplitDiff: "auto",
797+
SkipRewordInEditorWarning: false,
798+
SkipSwitchWorktreeOnCheckoutWarning: false,
799+
ScreenMode: "normal",
800+
Border: "rounded",
801+
AnimateExplosion: true,
802+
PortraitMode: "auto",
803+
FilterMode: "substring",
801804
Spinner: SpinnerConfig{
802805
Frames: []string{"|", "/", "-", "\\"},
803806
Rate: 50,

pkg/gui/controllers/branches_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func (self *BranchesController) promptToCheckoutWorktree(worktree *models.Worktr
420420
"worktreeName": worktree.Name,
421421
})
422422

423-
self.c.Confirm(types.ConfirmOpts{
423+
self.c.ConfirmIf(!self.c.UserConfig().Gui.SkipSwitchWorktreeOnCheckoutWarning, types.ConfirmOpts{
424424
Title: self.c.Tr.SwitchToWorktree,
425425
Prompt: prompt,
426426
HandleConfirm: func() error {

schema/config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,11 @@
532532
"description": "If true, do not show a warning when rewording a commit via an external editor",
533533
"default": false
534534
},
535+
"skipSwitchWorktreeOnCheckoutWarning": {
536+
"type": "boolean",
537+
"description": "If true, switch to a different worktree without confirmation when checking out a branch that is checked out in that worktree",
538+
"default": false
539+
},
535540
"sidePanelWidth": {
536541
"type": "number",
537542
"maximum": 1,

0 commit comments

Comments
 (0)