Skip to content

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

@jennybc

Description

@jennybc
Member

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

gaborcsardi commented on Dec 17, 2024

@gaborcsardi
Member

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

jennybc

jennybc commented on Dec 17, 2024

@jennybc
MemberAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jennybc@gaborcsardi

        Issue actions

          Consider `{.open some/path/to/whatever.xlsx}` as a way of delegating a file path to the OS · Issue #743 · r-lib/cli