-
Notifications
You must be signed in to change notification settings - Fork 73
Description
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.
Activity
gaborcsardi commentedon Dec 17, 2024
I wonder if this is something that could be configured by the end user, instead of the IDE and the package developer?
jennybc commentedon 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:
file://
links, though not in RStudio (or Positron's R console, which is emulating RStudio)product://
links, where the construction of said links might come from using an auto-detected template or user opt-inBecause it really comes down to how likely it is that the file is plain text versus something else.