Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider {.open some/path/to/whatever.xlsx} as a way of delegating a file path to the OS #743

Open
jennybc opened this issue Dec 16, 2024 · 2 comments

Comments

@jennybc
Copy link
Member

jennybc commented Dec 16, 2024

https://cli.r-lib.org/reference/links.html#default-handler

In RStudio file: URLs open within RStudio. If you click on a file link outside of RStudio, typically the operating system is consulted for the application to open it.

It might be interesting to have markup that produces the more common behaviour for a file hyperlink, i.e. to delegate opening to the OS.

In terms of mindset, then it becomes clear that .file is for file hyperlinks that you want to open "in this product", where the product might be RStudio or Positron (or VS Code). So probably a plain text file (maybe an image?). And .open (or some other designation) is for files where the OS should be consulted re: how to open. Like an Excel workbook or a Word document.

Context: In terminals in Positron/VS Code, file: hyperlinks are delegated to the OS and there's basically no way to intervene in that. (In the Positron R console, we can intervene and create behaviour similar to RStudio.) So in Positron/VS Code terminals, file hyperlinks that should open "in this product" have to be produced using a special URL scheme, e.g. vscode://file/{full path to file} or positron://file/{full path to file}.

https://code.visualstudio.com/docs/editor/command-line#_opening-vs-code-with-urls

This issue is related to a side point made in #601.

In hindsight, maybe it would have been good to introduce a scheme like rstudio://file{full path to file}, but I imagine that ship has sailed and it wouldn't make sense to reopen it.

Other interesting features supported by the vscode: and positron: scheme: can also be used to open a workspace (folder) or to go directly to the configuration for a setting.

@gaborcsardi
Copy link
Member

I wonder if this is something that could be configured by the end user, instead of the IDE and the package developer?

@jennybc
Copy link
Member Author

jennybc commented Dec 17, 2024

I tend to think the person writing the code (vs the person running the code) is in the best position to know which behaviour is desired:

  • Open with whatever the OS thinks is "best" = typical behaviour for file:// links, though not in RStudio (or Positron's R console, which is emulating RStudio)
  • Open with "the current product" = typical behaviour for product:// links, where the construction of said links might come from using an auto-detected template or user opt-in

Because it really comes down to how likely it is that the file is plain text versus something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants