Skip to content

Commit

Permalink
support RStudio Pro
Browse files Browse the repository at this point in the history
  • Loading branch information
msberends committed Apr 23, 2024
1 parent 23f1acf commit f53b5e7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: certeprojects
Title: A Certe R Package for Department Projects
Version: 1.20.17
Version: 1.20.18
Authors@R: c(
person(given = c("Matthijs", "S."),
family = "Berends",
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ importFrom(rstudioapi,initializeProject)
importFrom(rstudioapi,isAvailable)
importFrom(rstudioapi,navigateToFile)
importFrom(rstudioapi,openProject)
importFrom(rstudioapi,registerCommandCallback)
importFrom(rstudioapi,showDialog)
importFrom(rstudioapi,showPrompt)
importFrom(rstudioapi,showQuestion)
importFrom(rstudioapi,unregisterCommandCallback)
importFrom(shiny,HTML)
importFrom(shiny,a)
importFrom(shiny,actionButton)
Expand Down
12 changes: 8 additions & 4 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#' @importFrom callr r_bg
#' @importFrom AzureGraph create_graph_login
#' @importFrom rstudioapi registerCommandCallback isAvailable
#' @importFrom rstudioapi isAvailable
.onAttach <- function(...) {
# connect on attach with a background R process
# this will make sure that using Outlook, Planner, or Teams can be done instantly
Expand All @@ -44,7 +44,8 @@
# TODO remove the FALSE here to make it work
if (FALSE && interactive() && isAvailable()) {
try(
pkg_env$save_handle <- registerCommandCallback(
# use rstudioapi:: here, to support RStudio Pro which does not contain this function
pkg_env$save_handle <- rstudioapi::registerCommandCallback(
commandId = "saveSourceDoc",
callback = function() {
tryCatch(rs_teams_save(), error = function(e) packageStartupMessage("Could not upload to Teams: ", e$message))
Expand All @@ -53,10 +54,13 @@
}
}

#' @importFrom rstudioapi unregisterCommandCallback isAvailable
#' @importFrom rstudioapi isAvailable
.onDetach <- function(...) {
# TODO remove the FALSE here to make it work
if (FALSE && interactive() && isAvailable()) {
unregisterCommandCallback(handle = pkg_env$save_handle)
try(
# use rstudioapi:: here, to support RStudio Pro which does not contain this function
rstudioapi::unregisterCommandCallback(handle = pkg_env$save_handle),
silent = TRUE)
}
}
6 changes: 4 additions & 2 deletions man/knit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f53b5e7

Please sign in to comment.