summaryrefslogtreecommitdiff
path: root/cli/lsp
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp')
-rw-r--r--cli/lsp/language_server.rs13
-rw-r--r--cli/lsp/tsc.rs7
2 files changed, 17 insertions, 3 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index fdda1aeec..30a2ce253 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -2814,9 +2814,16 @@ impl Inner {
self.client.show_message(MessageType::WARNING, err).await;
}
- // now that we have dependencies loaded, we need to re-analyze them and
- // invalidate some diagnostics
- self.diagnostics_server.invalidate(&[referrer]);
+ // Now that we have dependencies loaded, we need to re-analyze all the files.
+ // For that we're invalidating all the existing diagnostics and restarting
+ // the language server for TypeScript (as it might hold to some stale
+ // documents).
+ self.diagnostics_server.invalidate_all();
+ let _: bool = self
+ .ts_server
+ .request(self.snapshot(), tsc::RequestMethod::Restart)
+ .await
+ .unwrap();
self.send_diagnostics_update();
self.send_testing_update();
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index 2a5bdc2d8..76e428b2f 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -2871,6 +2871,9 @@ pub enum RequestMethod {
ProvideCallHierarchyIncomingCalls((ModuleSpecifier, u32)),
/// Resolve outgoing call hierarchy items for a specific position.
ProvideCallHierarchyOutgoingCalls((ModuleSpecifier, u32)),
+
+ // Special request, used only internally by the LSP
+ Restart,
}
impl RequestMethod {
@@ -3084,6 +3087,10 @@ impl RequestMethod {
"position": position
})
}
+ RequestMethod::Restart => json!({
+ "id": id,
+ "method": "restart",
+ }),
}
}
}