From 9e7018db8a63c4ddbd073e0967151eb05a75c84b Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Wed, 9 Aug 2023 20:59:46 +1000 Subject: [PATCH] Honour editInTerminal value when opening a worktree folder There was no good reason not to do this in the first place. --- pkg/commands/git_commands/file.go | 6 +++--- pkg/config/editor_presets.go | 4 ++-- pkg/gui/controllers/helpers/files_helper.go | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/commands/git_commands/file.go b/pkg/commands/git_commands/file.go index 7efdb567a..9fd5e8929 100644 --- a/pkg/commands/git_commands/file.go +++ b/pkg/commands/git_commands/file.go @@ -131,15 +131,15 @@ func (self *FileCommands) GetEditAtLineAndWaitCmdStr(filename string, lineNumber return cmdStr } -func (self *FileCommands) GetOpenDirInEditorCmdStr(path string) string { - template := config.GetOpenDirInEditorTemplate(&self.UserConfig.OS, self.guessDefaultEditor) +func (self *FileCommands) GetOpenDirInEditorCmdStr(path string) (string, bool) { + template, editInTerminal := config.GetOpenDirInEditorTemplate(&self.UserConfig.OS, self.guessDefaultEditor) templateValues := map[string]string{ "dir": self.cmd.Quote(path), } cmdStr := utils.ResolvePlaceholderString(template, templateValues) - return cmdStr + return cmdStr, editInTerminal } func (self *FileCommands) guessDefaultEditor() string { diff --git a/pkg/config/editor_presets.go b/pkg/config/editor_presets.go index 121401424..92374280b 100644 --- a/pkg/config/editor_presets.go +++ b/pkg/config/editor_presets.go @@ -28,13 +28,13 @@ func GetEditAtLineAndWaitTemplate(osConfig *OSConfig, guessDefaultEditor func() return template } -func GetOpenDirInEditorTemplate(osConfig *OSConfig, guessDefaultEditor func() string) string { +func GetOpenDirInEditorTemplate(osConfig *OSConfig, guessDefaultEditor func() string) (string, bool) { preset := getPreset(osConfig, guessDefaultEditor) template := osConfig.OpenDirInEditor if template == "" { template = preset.openDirInEditorTemplate } - return template + return template, getEditInTerminal(osConfig, preset) } type editPreset struct { diff --git a/pkg/gui/controllers/helpers/files_helper.go b/pkg/gui/controllers/helpers/files_helper.go index 8f9a816f8..18c7bcedc 100644 --- a/pkg/gui/controllers/helpers/files_helper.go +++ b/pkg/gui/controllers/helpers/files_helper.go @@ -38,10 +38,9 @@ func (self *FilesHelper) EditFileAtLineAndWait(filename string, lineNumber int) } func (self *FilesHelper) OpenDirInEditor(path string) error { - cmdStr := self.c.Git().File.GetOpenDirInEditorCmdStr(path) + cmdStr, editInTerminal := self.c.Git().File.GetOpenDirInEditorCmdStr(path) - // Not editing in terminal because surely that's not a thing. - return self.callEditor(cmdStr, false) + return self.callEditor(cmdStr, editInTerminal) } func (self *FilesHelper) callEditor(cmdStr string, editInTerminal bool) error {