-
Notifications
You must be signed in to change notification settings - Fork 70
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
Make x-r-whatever
-style hyperlinks configurable
#739
Conversation
Looks good to me' |
.run
hyperlinks configurablex-r-whatever
-style hyperlinks configurable
get_config_chr <- function(x, default = NULL) { | ||
opt <- getOption(paste0("cli.", tolower(x))) | ||
if (!is.null(opt)) { | ||
stopifnot(is_string(opt)) | ||
return(opt) | ||
} | ||
|
||
env <- Sys.getenv(paste0("R_CLI_", toupper(x)), NA_character_) | ||
if (!is.na(env)) return(env) | ||
|
||
default | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For everything I've touched, configuration is possible:
- Via an option or an env var. Context: in the Positron R console, options are easier for us (or at least that was true at some earlier point? but I have no reason to believe anything has changed). However, for R package dev tasks that run in a separate R process in an integrated terminal, env vars work much better.
- The option is consulted first. There was precedent for this.
positron://positron.positron-r/cli?command=x-r-run:{code} | ||
``` | ||
|
||
(For backwards compatibility with older versions of RStudio, in some contexts, a legacy format is used, e.g. `ide:run:{code}`.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I have this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what you mean. Don't we always use ide::run
in RStudio?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we always use ide::run in RStudio?
I am finding it hard to actually figure this out. The RStudio detection logic is pretty complicated.
I thought there was some plan to start using the x-r-*
format in RStudio as well and to phase out the legacy format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK @gaborcsardi this has been promoted to a real PR now. Will you re-review? I think it's close. |
Do I understand it correctly that you are going to set the env vars to turn on hyperlinks in Positron tests? If yes, then is it going to cause problems that the env vars will be inherited in subprocesses, and those will also produce hyperlinks? E.g. if a test case knits an Rmd file, that'll potentially have ANSI escapes in the output? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! The tests pass, so I am fine with this. :)
Yes, I intend to set these env vars when Positron runs tests in a separate R process, i.e. not in the R console. So this would apply to the command "R: Test R Package", which runs Is it going to cause problems? Well, I think the problems are solvable if it does and are problems worth solving. I.e. it's a matter of test hygiene. cli itself passes its own tests, with this PR, with Positron's "R: Test R Package" command. And I assume that cli is the package most likely to experience problems. I did have to add cli/tests/testthat/test-ansi-hyperlink.R Line 243 in ef04608
And this issue is why the new options/env vars have been added to |
I just re-verified that cli passes its own tests, installed from this PR, inside a dev build of Positron, in which I'm setting these new env vars to make But there's one worth discussing:
I wanted to set this to The OSC 8 hyperlink "spec" says that |
If you are fine with |
I think this can be merged, but I've identified one problem: If an I'm struggling to understand why this happens, given that such hyperlinks do appear even when If you don't immediately see whatever it is that I'm missing, I propose we merge this so I can move forward in Positron. Then we can return to the matter, once you can see exactly what I'm talking about using a daily build. |
Relates to posit-dev/positron#5231
This is about making cli hyperlinks work when positron-r carries out package dev tasks, such as
devtools::test()
in an integrated terminal. An extension can contribute a URI handler, but only URIs with a very specific format are routed into the handler.