mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
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
This commit is contained in:
parent
15f5f74eb7
commit
0973e8e859
2 changed files with 52 additions and 4 deletions
|
@ -974,7 +974,7 @@ impl Inner {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
lsp_log!(
|
lsp_log!(
|
||||||
"Setting import map from workspace settings: \"{}\"",
|
"Using import map from workspace settings: \"{}\"",
|
||||||
import_map_str
|
import_map_str
|
||||||
);
|
);
|
||||||
if let Some(config_file) = self.config.maybe_config_file() {
|
if let Some(config_file) = self.config.maybe_config_file() {
|
||||||
|
@ -3685,9 +3685,11 @@ impl Inner {
|
||||||
self.maybe_package_json.clone(),
|
self.maybe_package_json.clone(),
|
||||||
force_global_cache,
|
force_global_cache,
|
||||||
)?;
|
)?;
|
||||||
cli_options.set_import_map_specifier(
|
// don't use the specifier in self.maybe_import_map because it's not
|
||||||
self.maybe_import_map.as_ref().map(|m| m.base_url().clone()),
|
// necessarily an import map specifier (could be a deno.json)
|
||||||
);
|
if let Some(import_map) = self.resolve_import_map_specifier()? {
|
||||||
|
cli_options.set_import_map_specifier(Some(import_map));
|
||||||
|
}
|
||||||
|
|
||||||
let open_docs = self.documents.documents(DocumentsFilter::OpenDiagnosable);
|
let open_docs = self.documents.documents(DocumentsFilter::OpenDiagnosable);
|
||||||
Ok(Some(PrepareCacheResult {
|
Ok(Some(PrepareCacheResult {
|
||||||
|
|
|
@ -349,6 +349,7 @@ fn lsp_import_map_embedded_in_config_file() {
|
||||||
temp_dir.write(
|
temp_dir.write(
|
||||||
"deno.embedded_import_map.jsonc",
|
"deno.embedded_import_map.jsonc",
|
||||||
r#"{
|
r#"{
|
||||||
|
// some comment
|
||||||
"imports": {
|
"imports": {
|
||||||
"/~/": "./lib/"
|
"/~/": "./lib/"
|
||||||
}
|
}
|
||||||
|
@ -654,6 +655,51 @@ fn lsp_import_map_config_file_auto_discovered_symlink() {
|
||||||
client.shutdown();
|
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]
|
#[test]
|
||||||
fn lsp_import_map_node_specifiers() {
|
fn lsp_import_map_node_specifiers() {
|
||||||
let context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
let context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||||
|
|
Loading…
Add table
Reference in a new issue