Skip to content

Commit

Permalink
rstudio vs positron
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Nov 14, 2024
1 parent b2f277e commit 18d1768
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions R/posit.R
Original file line number Diff line number Diff line change
@@ -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)
}


0 comments on commit 18d1768

Please sign in to comment.