diff --git a/R/aab-rstudio-detect.R b/R/aab-rstudio-detect.R index 3bd329bd..a295c846 100644 --- a/R/aab-rstudio-detect.R +++ b/R/aab-rstudio-detect.R @@ -32,8 +32,13 @@ rstudio <- local({ args = commandArgs(), search = search() ) - d$ver <- if (d$api) asNamespace("rstudioapi")$getVersion() - d$desktop <- if (d$api) asNamespace("rstudioapi")$versionInfo()$mode + + if (d$api) { + ns <- asNamespace("rstudioapi") + d$ver <- if (d$api) ns$getVersion() + new_api <- package_version(getNamespaceVersion(ns)) >= "0.17.0" + d$desktop <- if (new_api) ns$getMode() else ns$versionInfo()$mode + } d }