mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	Add config option gui.skipSwitchWorktreeOnCheckoutWarning (#4964)
Adds a config option that disables the confirmation for switching to a worktree when trying to check out a branch that is checked out in that other worktree. Fixes #4938.
This commit is contained in:
		| @@ -91,6 +91,10 @@ gui: | ||||
|   # If true, do not show a warning when rewording a commit via an external editor | ||||
|   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 | ||||
|   # 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. | ||||
|   | ||||
| @@ -84,6 +84,8 @@ type GuiConfig struct { | ||||
| 	SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"` | ||||
| 	// If true, do not show a warning when rewording a commit via an external editor | ||||
| 	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. | ||||
| 	// Number from 0 to 1.0. | ||||
| 	SidePanelWidth float64 `yaml:"sidePanelWidth" jsonschema:"maximum=1,minimum=0"` | ||||
| @@ -772,32 +774,33 @@ func GetDefaultConfig() *UserConfig { | ||||
| 				UnstagedChangesColor:            []string{"red"}, | ||||
| 				DefaultFgColor:                  []string{"default"}, | ||||
| 			}, | ||||
| 			CommitLength:                 CommitLengthConfig{Show: true}, | ||||
| 			SkipNoStagedFilesWarning:     false, | ||||
| 			ShowListFooter:               true, | ||||
| 			ShowCommandLog:               true, | ||||
| 			ShowBottomLine:               true, | ||||
| 			ShowPanelJumps:               true, | ||||
| 			ShowFileTree:                 true, | ||||
| 			ShowRootItemInFileTree:       true, | ||||
| 			ShowNumstatInFilesView:       false, | ||||
| 			ShowRandomTip:                true, | ||||
| 			ShowIcons:                    false, | ||||
| 			NerdFontsVersion:             "", | ||||
| 			ShowFileIcons:                true, | ||||
| 			CommitAuthorShortLength:      2, | ||||
| 			CommitAuthorLongLength:       17, | ||||
| 			CommitHashLength:             8, | ||||
| 			ShowBranchCommitHash:         false, | ||||
| 			ShowDivergenceFromBaseBranch: "none", | ||||
| 			CommandLogSize:               8, | ||||
| 			SplitDiff:                    "auto", | ||||
| 			SkipRewordInEditorWarning:    false, | ||||
| 			ScreenMode:                   "normal", | ||||
| 			Border:                       "rounded", | ||||
| 			AnimateExplosion:             true, | ||||
| 			PortraitMode:                 "auto", | ||||
| 			FilterMode:                   "substring", | ||||
| 			CommitLength:                        CommitLengthConfig{Show: true}, | ||||
| 			SkipNoStagedFilesWarning:            false, | ||||
| 			ShowListFooter:                      true, | ||||
| 			ShowCommandLog:                      true, | ||||
| 			ShowBottomLine:                      true, | ||||
| 			ShowPanelJumps:                      true, | ||||
| 			ShowFileTree:                        true, | ||||
| 			ShowRootItemInFileTree:              true, | ||||
| 			ShowNumstatInFilesView:              false, | ||||
| 			ShowRandomTip:                       true, | ||||
| 			ShowIcons:                           false, | ||||
| 			NerdFontsVersion:                    "", | ||||
| 			ShowFileIcons:                       true, | ||||
| 			CommitAuthorShortLength:             2, | ||||
| 			CommitAuthorLongLength:              17, | ||||
| 			CommitHashLength:                    8, | ||||
| 			ShowBranchCommitHash:                false, | ||||
| 			ShowDivergenceFromBaseBranch:        "none", | ||||
| 			CommandLogSize:                      8, | ||||
| 			SplitDiff:                           "auto", | ||||
| 			SkipRewordInEditorWarning:           false, | ||||
| 			SkipSwitchWorktreeOnCheckoutWarning: false, | ||||
| 			ScreenMode:                          "normal", | ||||
| 			Border:                              "rounded", | ||||
| 			AnimateExplosion:                    true, | ||||
| 			PortraitMode:                        "auto", | ||||
| 			FilterMode:                          "substring", | ||||
| 			Spinner: SpinnerConfig{ | ||||
| 				Frames: []string{"|", "/", "-", "\\"}, | ||||
| 				Rate:   50, | ||||
|   | ||||
| @@ -420,15 +420,13 @@ func (self *BranchesController) promptToCheckoutWorktree(worktree *models.Worktr | ||||
| 		"worktreeName": worktree.Name, | ||||
| 	}) | ||||
|  | ||||
| 	self.c.Confirm(types.ConfirmOpts{ | ||||
| 	return self.c.ConfirmIf(!self.c.UserConfig().Gui.SkipSwitchWorktreeOnCheckoutWarning, types.ConfirmOpts{ | ||||
| 		Title:  self.c.Tr.SwitchToWorktree, | ||||
| 		Prompt: prompt, | ||||
| 		HandleConfirm: func() error { | ||||
| 			return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY) | ||||
| 		}, | ||||
| 	}) | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (self *BranchesController) handleCreatePullRequest(selectedBranch *models.Branch) error { | ||||
|   | ||||
| @@ -532,6 +532,11 @@ | ||||
|           "description": "If true, do not show a warning when rewording a commit via an external editor", | ||||
|           "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": { | ||||
|           "type": "number", | ||||
|           "maximum": 1, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user