posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.82k stars 90 forks source link

`Sys.getenv("TERM_PROGRAM")` inside R console is currently `vscode` #5373

Closed maxheld83 closed 1 week ago

maxheld83 commented 1 week ago

I get that Positron is a VSCode fork, so this makes sense, but it can cause some problems when you have conditional logic which is expected to trigger only in the actual VSCode (and related R extensions), as for example in https://github.com/posit-dev/positron/issues/5338.

Might also just be more idiomatic to have it return positron (or ark?), since that's what it is.

maxheld83 commented 1 week ago

FYI, https://github.com/posit-dev/positron/issues/1494 already discusses/addresses this issue by setting an env-var "POSITRON", but perhaps disambiguation "TERM_PROGRAM" would also be beneficial.

juliasilge commented 1 week ago

FWIW this is as expected/designed and there would be a lot of work involved to update how this environment variable is used throughout the product, work that we don't think would be super impactful at the current time.

We do have some advice for R folks who use both VS Code and Positron in terms of .Rprofile:

if (interactive() && Sys.getenv("RSTUDIO") == "" && Sys.getenv("POSITRON") == "") {
    ## code you use for better terminal behavior for R in VS Code
}