Add "open with system default application" event to UI comm #8588
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #5486
Companion PR in ark: posit-dev/ark#877
This PR creates a new event in the UI comm that says "open this thing (file, presumably) with the default application according to the OS".
The immediate motivating example is to allow R's
browseURL()
to work as expected in the Positron console.Release Notes
New Features
browseURL()
in R now delegates to the operating system's default opener for inputs that are not recognized as a web URL or an HTML file.Bug Fixes
QA Notes
In R, use
browseURL()
on a local filepath. Exercise a couple of files (meaning file types) and a folder. Here are examples taken from the "R Code" column of the table at #5486 (comment):browseURL(tempdir())
temp_csv_file <- tempfile()
write.csv(iris, temp_csv_file)
browseURL(temp_csv_file)
temp_csv_file_with_ext <- tempfile(fileext = ".csv")
write.csv(iris, temp_csv_file_with_ext)
browseURL(temp_csv_file_with_ext)
.csv
(VS Code for me, haha)temp_html_file <- tempfile()
writeLines("<p>Hi!</p>", temp_html_file)
browseURL(temp_html_file)
temp_html_file_with_ext <- tempfile(fileext = ".html")
writeLines("<p>Hi!</p>", temp_html_file_with_ext)
browseURL(temp_html_file_with_ext)
.html
file in default external browserWhen in doubt, the behaviour we seek is whatever happens in R in a plain terminal or in RStudio Console.
We should definitely verify this on linux and Windows (I'm on macOS, so feel pretty confident about that).
As for tests, I don't really know how we would do that 🤔 in this case. The whole point is to open a file in some other application and exactly what that is will vary by OS / user.