summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-09-04 13:22:30 +0100
committerGitHub <noreply@github.com>2024-09-04 13:22:30 +0100
commit84dc375b2d28a0ba9ddf0fbc5168505c19b1adea (patch)
tree5e55570a55da3e5f2261c11bb3b17df49b85e0bb
parent0e0a5c24ea8b17d410c30bf3fcb70c749b35f8b3 (diff)
fix(lsp): update diagnostics on npm install (#25352)
-rw-r--r--cli/lsp/config.rs11
-rw-r--r--tests/integration/lsp_tests.rs46
2 files changed, 53 insertions, 4 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs
index d204dce64..f9262d12e 100644
--- a/cli/lsp/config.rs
+++ b/cli/lsp/config.rs
@@ -1697,9 +1697,14 @@ impl ConfigTree {
}
pub fn is_watched_file(&self, specifier: &ModuleSpecifier) -> bool {
- if specifier.path().ends_with("/deno.json")
- || specifier.path().ends_with("/deno.jsonc")
- || specifier.path().ends_with("/package.json")
+ let path = specifier.path();
+ if path.ends_with("/deno.json")
+ || path.ends_with("/deno.jsonc")
+ || path.ends_with("/package.json")
+ || path.ends_with("/node_modules/.package-lock.json")
+ || path.ends_with("/node_modules/.yarn-integrity.json")
+ || path.ends_with("/node_modules/.modules.yaml")
+ || path.ends_with("/node_modules/.deno/.setup-cache.bin")
{
return true;
}
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index 7c7e9315c..4693b7222 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -14767,7 +14767,6 @@ fn lsp_byonm() {
"@denotest/esm-basic": "*",
},
}));
- context.run_npm("install");
let mut client = context.new_lsp_command().build();
client.initialize_default();
let diagnostics = client.did_open(json!({
@@ -14800,6 +14799,51 @@ fn lsp_byonm() {
"source": "deno",
"message": "Could not find a matching package for 'npm:chalk' in a package.json file. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.",
},
+ {
+ "range": {
+ "start": {
+ "line": 2,
+ "character": 15,
+ },
+ "end": {
+ "line": 2,
+ "character": 36,
+ },
+ },
+ "severity": 1,
+ "code": "resolver-error",
+ "source": "deno",
+ "message": "Could not resolve \"@denotest/esm-basic\", but found it in a package.json. Deno expects the node_modules/ directory to be up to date. Did you forget to run `deno install`?",
+ },
+ ])
+ );
+ context.run_npm("install");
+ client.did_change_watched_files(json!({
+ "changes": [{
+ "uri": temp_dir.url().join("node_modules/.package-lock.json").unwrap(),
+ "type": 1,
+ }],
+ }));
+ let diagnostics = client.read_diagnostics();
+ assert_eq!(
+ json!(diagnostics.all()),
+ json!([
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 15,
+ },
+ "end": {
+ "line": 1,
+ "character": 26,
+ },
+ },
+ "severity": 1,
+ "code": "resolver-error",
+ "source": "deno",
+ "message": "Could not find a matching package for 'npm:chalk' in a package.json file. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.",
+ },
])
);
client.shutdown();