Skip to content

Commit

Permalink
Fix attach globals in diagnose_file
Browse files Browse the repository at this point in the history
  • Loading branch information
renkun-ken committed Oct 16, 2022
1 parent 6a56d74 commit 8b27a18
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ diagnose_file <- function(uri, content, is_rmarkdown = FALSE, globals = NULL, ca
}

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

lints <- lintr::lint(path, cache = cache, text = content)
diagnostics <- lapply(lints, diagnostic_from_lint, content = content)
names(diagnostics) <- NULL
diagnostics
Expand Down

0 comments on commit 8b27a18

Please sign in to comment.