Skip to content

Commit 65c2956

Browse files
committed
remove .vscode detection
1 parent 79b05ca commit 65c2956

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

R/utils-projects.R

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#'
2525
#' - Fallback to intelligent project root detection using [xfun::proj_root()] for interactive sessions:
2626
#' - `_quarto.yml` or `_quarto.yaml` (Quarto project files)
27-
#' - `.vscode` directory (VS Code/Positron workspace)
2827
#' - `DESCRIPTION` file with `Package:` field (R package or Project)
2928
#' - `.Rproj` files with `Version:` field (RStudio projects)
3029
#'
@@ -80,8 +79,8 @@ project_path <- function(..., root = NULL) {
8079
Sys.getenv("QUARTO_PROJECT_DIR")
8180
)
8281

83-
if (nzchar(quarto_root)) {
84-
root <- quarto_root
82+
root <- if (nzchar(quarto_root)) {
83+
quarto_root
8584
} else {
8685
# Try to find project root using xfun::proj_root() with extended rules
8786
tryCatch(
@@ -92,19 +91,17 @@ project_path <- function(..., root = NULL) {
9291
# which are only set when running Quarto commands
9392
c("_quarto.yml", ""), # Quarto project config
9493
c("_quarto.yaml", ""), # Alternative Quarto config
95-
# This is to provide some better fallback than just the working directory
96-
c(".vscode", ""), # VS Code/Positron workspace
9794
xfun::root_rules # Default rules (DESCRIPTION, .Rproj)
9895
)
9996

10097
proj_root <- xfun::proj_root(rules = extended_rules)
101-
root <- if (!is.null(proj_root)) {
98+
if (!is.null(proj_root)) {
10299
proj_root
103100
} else {
104-
cli::cli_warn(
101+
cli::cli_warn(c(
105102
"Failed to determine project root using {.fun xfun::proj_root}. Using current working directory.",
106103
">" = "This may lead to different behavior interactively vs running Quarto commands."
107-
)
104+
))
108105
getwd()
109106
}
110107
},
@@ -114,16 +111,25 @@ project_path <- function(..., root = NULL) {
114111
"Failed to determine project root: {e$message}. Using current working directory as a fallback.",
115112
">" = "This may lead to different behavior interactively vs running Quarto commands."
116113
))
117-
root <- getwd()
114+
getwd() # Return the working directory
118115
}
119116
)
120117
}
121118
}
122119

123120
# Use xfun::from_root for better path handling
124-
path <- tryCatch(
125-
xfun::from_root(..., root = root, error = FALSE),
126-
error = function(e) file.path(root, ...)
121+
path <- rlang::try_fetch(
122+
xfun::from_root(..., root = root, error = TRUE),
123+
error = function(e) {
124+
rlang::abort(
125+
c(
126+
"Failed to construct project path",
127+
">" = "Ensure you are using valid path components."
128+
),
129+
parent = e,
130+
call = rlang::caller_env()
131+
)
132+
}
127133
)
128134
path
129135
}

0 commit comments

Comments
 (0)