diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-08-10 17:23:58 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 17:23:58 +1000 |
commit | c43830b0271374ab42e83771479bf757ba34839c (patch) | |
tree | b7036d76b28a624a8f573bed5c0c7f63ee366d1c /pkg/gui | |
parent | 08624b8ef724e1c83fcaffea7d72765414065e01 (diff) | |
parent | 9c5eedf748aaf26ed2042aa20babc42fa13eca41 (diff) |
Support editing files in existing neovim instance (#2916)
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/controllers/helpers/files_helper.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/pkg/gui/controllers/helpers/files_helper.go b/pkg/gui/controllers/helpers/files_helper.go index 8f9a816f8..140a71127 100644 --- a/pkg/gui/controllers/helpers/files_helper.go +++ b/pkg/gui/controllers/helpers/files_helper.go @@ -19,33 +19,32 @@ func NewFilesHelper(c *HelperCommon) *FilesHelper { var _ IFilesHelper = &FilesHelper{} func (self *FilesHelper) EditFile(filename string) error { - cmdStr, editInTerminal := self.c.Git().File.GetEditCmdStr(filename) - return self.callEditor(cmdStr, editInTerminal) + cmdStr, suspend := self.c.Git().File.GetEditCmdStr(filename) + return self.callEditor(cmdStr, suspend) } func (self *FilesHelper) EditFileAtLine(filename string, lineNumber int) error { - cmdStr, editInTerminal := self.c.Git().File.GetEditAtLineCmdStr(filename, lineNumber) - return self.callEditor(cmdStr, editInTerminal) + cmdStr, suspend := self.c.Git().File.GetEditAtLineCmdStr(filename, lineNumber) + return self.callEditor(cmdStr, suspend) } func (self *FilesHelper) EditFileAtLineAndWait(filename string, lineNumber int) error { cmdStr := self.c.Git().File.GetEditAtLineAndWaitCmdStr(filename, lineNumber) - // Always suspend, regardless of the value of the editInTerminal config, + // Always suspend, regardless of the value of the suspend config, // since we want to prevent interacting with the UI until the editor // returns, even if the editor doesn't use the terminal return self.callEditor(cmdStr, true) } func (self *FilesHelper) OpenDirInEditor(path string) error { - cmdStr := self.c.Git().File.GetOpenDirInEditorCmdStr(path) + cmdStr, suspend := 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, suspend) } -func (self *FilesHelper) callEditor(cmdStr string, editInTerminal bool) error { - if editInTerminal { +func (self *FilesHelper) callEditor(cmdStr string, suspend bool) error { + if suspend { return self.c.RunSubprocessAndRefresh( self.c.OS().Cmd.NewShell(cmdStr), ) |