Skip to content

Cannot open files by system default application (VS Code) #105

Description

@Myriad-Dreamin

Context: Myriad-Dreamin/tinymist#837

I want to have a robust way to open files by system default application. I simply use open crate by:

log::info!("open with system default apps: {path:?}");
if let Err(e) = ::open::that_detached(path) {
    log::error!("failed to open with system default apps: {e}");
};

At first glance, it worked well when I set default application as Adobe Acrobat or Edge. But I saw node-package-open's limitation,

This extension use two ways to open file in external applications.

1. Node package: open

This package has one limit that can't open a file which is also made by electron. For example, you can't open md file in typora using this package. The openCommand, args configuration item is also supported by this package. When isElectronApp: false(by default), extension will use this way.

I was interested in checking whether our implementation worked in the case. Then I set the default application to "Visual Studio Code".

image

❎ But unluckily, it silently failed.

  • ✅ I then double clicked the pdf file, explorer helped me to open the file in "Visual Studio Code".

  • ✅ I also ran the command in console, it worked:

    cmd /c start "" "c:\\Users\\xxx\\test.pdf"
    
  • ❎ I have also tested opener, they silently failed as well.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions