diff --git a/R/dev-help.R b/R/dev-help.R index bb334d8b..80d30173 100644 --- a/R/dev-help.R +++ b/R/dev-help.R @@ -89,7 +89,7 @@ print.dev_topic <- function(x, ...) { type <- arg_match0(x$type %||% "text", c("text", "html")) # Use rstudio's previewRd() if possible - if (type == "html" && is_rstudio() && is_installed("rstudioapi")) { + if (type == "html" && rstudioapi_available()) { # If the package has Rd macros, this needs a version of rstudio # that loads them, see rstudio/rstudio#12111 version_needed <- if (has_rd_macros(dirname(dirname(x$path)))) "2022.12.0.256" diff --git a/R/utils.R b/R/utils.R index d0214306..fa7ae276 100644 --- a/R/utils.R +++ b/R/utils.R @@ -203,3 +203,7 @@ cat_line <- function(...) { is_rstudio <- function() { is_string(.Platform$GUI, "RStudio") } + +rstudioapi_available <- function() { + is_installed("rstudioapi") && rstudioapi::isAvailable() +}