From dd6d19e12051fac2ea5639f621501f4710a1b8e1 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Wed, 3 Jul 2024 20:25:42 +0100 Subject: fix(lsp): correct scope attribution for injected @types/node (#24404) --- tests/integration/lsp_tests.rs | 63 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'tests/integration') diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index e05e182cb..d0df5e6e8 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -8606,6 +8606,69 @@ fn lsp_completions_node_specifier() { client.shutdown(); } +#[test] +fn lsp_completions_node_specifier_node_modules_dir() { + let context = TestContextBuilder::new() + .use_http_server() + .use_temp_cwd() + .build(); + let temp_dir = context.temp_dir(); + temp_dir.write( + temp_dir.path().join("deno.json"), + json!({ + "nodeModulesDir": true, + }) + .to_string(), + ); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + client.did_open(json!({ + "textDocument": { + "uri": temp_dir.uri().join("file.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": "import fs from \"node:fs\";\n", + }, + })); + client.write_request( + "workspace/executeCommand", + json!({ + "command": "deno.cache", + "arguments": [[], temp_dir.uri().join("file.ts").unwrap()], + }), + ); + client.write_notification( + "textDocument/didChange", + json!({ + "textDocument": { + "uri": temp_dir.uri().join("file.ts").unwrap(), + "version": 2, + }, + "contentChanges": [ + { + "range": { + "start": { "line": 1, "character": 0 }, + "end": { "line": 1, "character": 0 }, + }, + "text": "fs.", + }, + ], + }), + ); + let list = client.get_completion_list( + temp_dir.uri().join("file.ts").unwrap(), + (1, 3), + json!({ + "triggerKind": 2, + "triggerCharacter": ".", + }), + ); + assert!(!list.is_incomplete); + assert!(list.items.iter().any(|i| i.label == "writeFile")); + assert!(list.items.iter().any(|i| i.label == "writeFileSync")); + client.shutdown(); +} + #[test] fn lsp_completions_registry() { let context = TestContextBuilder::new() -- cgit v1.2.3