From 17fb69403b0e270f56524fd31e4f615201a20d6d Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Mon, 2 Dec 2024 17:52:49 -0700 Subject: [PATCH] Add shim for `rstudioapi::documentPath()` (#642) --- crates/ark/src/modules/rstudio/document-api.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/ark/src/modules/rstudio/document-api.R b/crates/ark/src/modules/rstudio/document-api.R index ea3277c9e..e4a96c832 100644 --- a/crates/ark/src/modules/rstudio/document-api.R +++ b/crates/ark/src/modules/rstudio/document-api.R @@ -33,7 +33,17 @@ )) } +#' @export +.rs.api.documentPath <- function(id = NULL) { + # TODO: Support document IDs + stopifnot(is.null(id)) + context <- .ps.ui.LastActiveEditorContext() + if (is.null(context)) { + return() + } + context$document$path +} #' @export .rs.api.getActiveDocumentContext <- function() {