Launch OpenFile command in sub process

This commit is contained in:
Mikhail Swift 2019-07-02 19:50:56 -04:00
parent 1ff2198c0a
commit e435636760
2 changed files with 5 additions and 8 deletions

View file

@ -128,15 +128,14 @@ func sanitisedCommandOutput(output []byte, err error) (string, error) {
} }
// OpenFile opens a file with the given // OpenFile opens a file with the given
func (c *OSCommand) OpenFile(filename string) error { func (c *OSCommand) OpenFile(filename string) (*exec.Cmd, error) {
commandTemplate := c.Config.UserConfig.OS.OpenCommand commandTemplate := c.Config.UserConfig.OS.OpenCommand
templateValues := map[string]string{ templateValues := map[string]string{
"filename": c.Quote(filename), "filename": c.Quote(filename),
} }
command := utils.ResolvePlaceholderString(commandTemplate, templateValues) command := c.ExecutableFromString(utils.ResolvePlaceholderString(commandTemplate, templateValues))
err := c.RunCommand(command) return command, nil
return err
} }
// OpenLink opens a file with the given // OpenLink opens a file with the given

View file

@ -345,10 +345,8 @@ func (gui *Gui) editFile(filename string) error {
} }
func (gui *Gui) openFile(filename string) error { func (gui *Gui) openFile(filename string) error {
if err := gui.OSCommand.OpenFile(filename); err != nil { _, err := gui.runSyncOrAsyncCommand(gui.OSCommand.OpenFile(filename))
return gui.createErrorPanel(gui.g, err.Error()) return err
}
return nil
} }
// runSyncOrAsyncCommand takes the output of a command that may have returned // runSyncOrAsyncCommand takes the output of a command that may have returned