diff --git a/R/posit.R b/R/posit.R index 1332a961..f3dea736 100644 --- a/R/posit.R +++ b/R/posit.R @@ -1,19 +1,16 @@ -is_posit <- function() { - tryCatch(rstudioapi::isAvailable(), error = function(e) FALSE) +# hack to detect Rstudio vs. Positron +is_rstudio <- function() { + tryCatch(rstudioapi::getThemeInfo(), error = function(e) FALSE) } -is_posit_notebook <- function() { +is_rstudio_notebook <- function() { flag <- FALSE - if (is_posit()) { - ## this returns a .Rmd/.qmd path in Positron, but Positron doesn't support inline tables - ## TODO: this is a very ugly hack: https://github.com/rstudio/rstudioapi/issues/310 - # con <- rstudioapi::getSourceEditorContext()[["path"]] - con <- rstudioapi::getActiveDocumentContext()[["path"]] + # inline doesn't work in Positron + if (is_rstudio()) { + con <- rstudioapi::getActiveDocumentContext()[["path"]] if (isTRUE(grepl("\\.qmd$|\\.Rmd$", con))) { flag <- TRUE } } return(flag) } - -