mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
fix(lsp): include mtime in tsc script version (#20911)
This commit is contained in:
parent
659cd90758
commit
7561f6ecea
2 changed files with 48 additions and 1 deletions
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue