1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-21 12:16:54 +02:00

Honour editInTerminal value when opening a worktree folder

There was no good reason not to do this in the first place.
This commit is contained in:
Jesse Duffield 2023-08-09 20:59:46 +10:00
parent cdea5b4873
commit 9e7018db8a
3 changed files with 7 additions and 8 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {