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
func (c *OSCommand) OpenFile(filename string) error {
func (c *OSCommand) OpenFile(filename string) (*exec.Cmd, error) {
commandTemplate := c.Config.UserConfig.OS.OpenCommand
templateValues := map[string]string{
"filename": c.Quote(filename),
}
command := utils.ResolvePlaceholderString(commandTemplate, templateValues)
err := c.RunCommand(command)
return err
command := c.ExecutableFromString(utils.ResolvePlaceholderString(commandTemplate, templateValues))
return command, nil
}
// 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 {
if err := gui.OSCommand.OpenFile(filename); err != nil {
return gui.createErrorPanel(gui.g, err.Error())
}
return nil
_, err := gui.runSyncOrAsyncCommand(gui.OSCommand.OpenFile(filename))
return err
}
// runSyncOrAsyncCommand takes the output of a command that may have returned