Skip to content

Commit 8b27a18

Browse files
committed
Fix attach globals in diagnose_file
1 parent 6a56d74 commit 8b27a18

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

R/diagnostics.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ diagnose_file <- function(uri, content, is_rmarkdown = FALSE, globals = NULL, ca
8585
}
8686

8787
if (length(globals)) {
88-
parent.env(globals) <- environment()
89-
lints <- with(globals, lintr::lint(path, cache = cache, text = content))
90-
} else {
91-
lints <- lintr::lint(path, cache = cache, text = content)
88+
env_name <- "languageserver:globals"
89+
do.call("attach", list(globals, name = env_name, warn.conflicts = FALSE))
90+
on.exit(do.call("detach", list(env_name, character.only = TRUE)))
9291
}
9392

93+
lints <- lintr::lint(path, cache = cache, text = content)
9494
diagnostics <- lapply(lints, diagnostic_from_lint, content = content)
9595
names(diagnostics) <- NULL
9696
diagnostics

0 commit comments

Comments
 (0)