diff --git a/pkg/commands/os.go b/pkg/commands/os.go index 9ce2d363..a76139a8 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -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 diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index a5eb08b1..e2b34687 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -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