1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

fix(lsp): include mtime in tsc script version (#20911)

This commit is contained in:
Nayeem Rahman 2023-10-17 05:13:06 +01:00 committed by GitHub
parent 659cd90758
commit 7561f6ecea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 1 deletions

View file

@ -574,7 +574,7 @@ impl Document {
pub fn script_version(&self) -> String {
self
.maybe_lsp_version()
.map(|v| v.to_string())
.map(|v| format!("{}+{v}", self.fs_version()))
.unwrap_or_else(|| self.fs_version().to_string())
}

View file

@ -8092,6 +8092,53 @@ fn lsp_diagnostics_refresh_dependents() {
assert_eq!(client.queue_len(), 0);
}
// Regression test for https://github.com/denoland/deno/issues/10897.
#[test]
fn lsp_ts_diagnostics_refresh_on_lsp_version_reset() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let temp_dir = context.temp_dir();
temp_dir.write("file.ts", r#"Deno.readTextFileSync(1);"#);
let mut client = context.new_lsp_command().build();
client.initialize_default();
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().len(), 1);
client.write_notification(
"textDocument/didClose",
json!({
"textDocument": {
"uri": temp_dir.uri().join("file.ts").unwrap(),
},
}),
);
temp_dir.remove_file("file.ts");
// VSCode opens with `version: 1` again because the file was deleted. Ensure
// diagnostics are still refreshed.
client.did_open_raw(json!({
"textDocument": {
"uri": temp_dir.uri().join("file.ts").unwrap(),
"languageId": "typescript",
"version": 1,
"text": "",
},
}));
temp_dir.write("file.ts", r#""#);
client.did_save(json!({
"textDocument": {
"uri": temp_dir.uri().join("file.ts").unwrap(),
},
}));
let diagnostics = client.read_diagnostics();
assert_eq!(diagnostics.all(), vec![]);
client.shutdown();
}
#[test]
fn lsp_npm_missing_type_imports_diagnostics() {
let context = TestContextBuilder::new()