Skip to content

Commit

Permalink
keep braces, add positron check
Browse files Browse the repository at this point in the history
  • Loading branch information
mihem committed Feb 1, 2025
1 parent 0831ada commit dd40635
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions R/rix_init.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,9 @@ rix_init <- function(project_path,
# first create the call, deparse it, and write it to .Rprofile
rprofile_quoted <- nix_rprofile()
rprofile_deparsed <- deparse_chr1(expr = rprofile_quoted, collapse = "\n")
rprofile_cleaned <- gsub(pattern = "^\\{|\\}$", replacement = "", x = rprofile_deparsed)
rprofile_file <- file.path(project_path, ".Rprofile")

rprofile_text <- get_rprofile_text(rprofile_cleaned)
rprofile_text <- get_rprofile_text(rprofile_deparsed)

# This function creates the connection, write the text
# and closes the connection
Expand Down Expand Up @@ -423,6 +422,7 @@ nix_rprofile <- function() {
is_rstudio <- Sys.getenv("RSTUDIO") == "1"
is_nix_r <- nzchar(Sys.getenv("NIX_STORE"))
is_code <- Sys.getenv("TERM_PROGRAM") == "vscode"
is_positron <- Sys.getenv("POSITRON") == "1"
if (isFALSE(is_nix_r) && isTRUE(is_rstudio)) {
# Currently, RStudio does not propagate environmental variables defined in
# `$HOME/.zshrc`, `$HOME/.bashrc` and alike. This is workaround to
Expand Down Expand Up @@ -483,11 +483,11 @@ nix_rprofile <- function() {
.libPaths(new_paths)
rm(current_paths, userlib_paths, user_dir, new_paths)
}

if (isTRUE(is_code) && interactive() && isFALSE(is_rstudio)) {
# source vscode-R init.R file for vscode-R
if (isTRUE(is_code) && interactive() && isFALSE(is_rstudio) && isFALSE(is_positron)) {
source(file.path(Sys.getenv(if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"), ".vscode-R", "init.R"))
}
rm(is_rstudio, is_nix_r, is_code)
rm(is_rstudio, is_nix_r, is_code, is_positron)
})
# nolint end: object_name
}

0 comments on commit dd40635

Please sign in to comment.