From 0973e8e8594cb01631306474cd4032245ef956cf Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 1 Mar 2024 21:13:04 -0500 Subject: fix(lsp): regression - caching in lsp broken when config with imports has comments (#22666) Caused by https://github.com/denoland/deno/pull/22553 Closes #22664 --- tests/integration/lsp_tests.rs | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests') diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 3ae738111..cbf272581 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -349,6 +349,7 @@ fn lsp_import_map_embedded_in_config_file() { temp_dir.write( "deno.embedded_import_map.jsonc", r#"{ + // some comment "imports": { "/~/": "./lib/" } @@ -654,6 +655,51 @@ fn lsp_import_map_config_file_auto_discovered_symlink() { client.shutdown(); } +#[test] +fn lsp_deno_json_imports_comments_cache() { + let context = TestContextBuilder::new() + .use_http_server() + .use_temp_cwd() + .build(); + let temp_dir = context.temp_dir(); + temp_dir.write( + "deno.jsonc", + r#"{ + // comment + "imports": { + "print_hello": "http://localhost:4545/import_maps/print_hello.ts", + }, + }"#, + ); + temp_dir.write( + "file.ts", + r#" + import { printHello } from "print_hello"; + printHello(); + "#, + ); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + client.write_request( + "workspace/executeCommand", + json!({ + "command": "deno.cache", + "arguments": [[], temp_dir.uri().join("file.ts").unwrap()], + }), + ); + + let diagnostics = client.did_open(json!({ + "textDocument": { + "uri": temp_dir.uri().join("file.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": temp_dir.read_to_string("file.ts"), + } + })); + assert_eq!(diagnostics.all(), vec![]); + client.shutdown(); +} + #[test] fn lsp_import_map_node_specifiers() { let context = TestContextBuilder::for_npm().use_temp_cwd().build(); -- cgit v1.2.3