rstudio / rstudioapi

Safely access RStudio's API (when available)
http://rstudio.github.io/rstudioapi
Other
165 stars 35 forks source link

Does rstudioapi need a way to detect if RStudio is running? #233

Open MilesMcBain opened 3 years ago

MilesMcBain commented 3 years ago

In many places in RStudio packages, rstudoapi::isAvailable() is used as a quick way to check if the user is running RStudio. This creates issues for VSCode where the rstudioapi is partially supported.

In some cases the use of rstudioapi::hasFun could be used instead to see if the desired functionality, rather than the RStudio IDE is present. Here is an example where that might make sense: https://github.com/r-lib/usethis/issues/1455

I expect in some cases that won't make sense and the rstudioapi may need some kind of isRStudio() function? Although I am little worried introducing something may lead to that being over used and unnecessarily lock VSCode users out of functionality.

Perhaps there needs to be some kind of API style-guide put together that talks about applying the minimally restrictive check? I'd be happy to contribute.

MilesMcBain commented 2 years ago

Possible example where this might be useful: https://github.com/r-spatial/mapview/issues/390