diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2024-06-18 23:00:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 00:00:17 +0200 |
commit | 810474d8b79738c29bd5fe975920169e03ec61b0 (patch) | |
tree | c8c275827966282dbf83f5e6e5fb26bfbc0c5f1e /tests/integration/lsp_tests.rs | |
parent | 5289c69271fed638571580bfb120c41bd6ea4372 (diff) |
fix(lsp): use import map from workspace root (#24246)
Follow up to #24206 which broke deno_std intellisense.
Diffstat (limited to 'tests/integration/lsp_tests.rs')
-rw-r--r-- | tests/integration/lsp_tests.rs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 3692bf7d9..0659bb439 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -12695,6 +12695,68 @@ fn lsp_deno_json_workspace_lint_config() { } #[test] +fn lsp_deno_json_workspace_import_map() { + let context = TestContextBuilder::new().use_temp_cwd().build(); + let temp_dir = context.temp_dir(); + temp_dir.create_dir_all("project1/project2"); + temp_dir.write( + "project1/deno.json", + json!({ + "workspaces": ["project2"], + "imports": { + "foo": "./foo1.ts", + }, + }) + .to_string(), + ); + temp_dir.write("project1/foo1.ts", ""); + temp_dir.write( + "project1/project2/deno.json", + // Should ignore and inherit import map from `project1/deno.json`. + json!({ + "imports": { + "foo": "./foo2.ts", + }, + }) + .to_string(), + ); + temp_dir.write("project1/project2/foo2.ts", ""); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + client.did_open(json!({ + "textDocument": { + "uri": temp_dir.uri().join("project1/project2/file.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": "import \"foo\";\n", + }, + })); + let res = client.write_request( + "textDocument/hover", + json!({ + "textDocument": { + "uri": temp_dir.uri().join("project1/project2/file.ts").unwrap(), + }, + "position": { "line": 0, "character": 7 }, + }), + ); + assert_eq!( + res, + json!({ + "contents": { + "kind": "markdown", + "value": format!("**Resolved Dependency**\n\n**Code**: file​{}\n", temp_dir.uri().join("project1/foo1.ts").unwrap().as_str().trim_start_matches("file")), + }, + "range": { + "start": { "line": 0, "character": 7 }, + "end": { "line": 0, "character": 12 }, + }, + }) + ); + client.shutdown(); +} + +#[test] fn lsp_deno_json_workspace_jsr_resolution() { let context = TestContextBuilder::new().use_temp_cwd().build(); let temp_dir = context.temp_dir(); |