@@ -964,22 +964,18 @@ impl Application {
964964 Notification::Exit => {
965965 self.editor.set_status("Language server exited");
966966
967− // Clear any diagnostics for documents with this server open.
968− let urls: Vec<_> = self
969− .editor
970− .documents_mut()
971− .filter_map(|doc| {
972− if doc.supports_language_server(server_id) {
973− doc.clear_diagnostics(server_id);
974− doc.url()
975− } else {
976− None
977− }
978− })
979− .collect();
967+ // LSPs may produce diagnostics for files that haven't been opened in helix,
968+ // we need to clear those and remove the entries from the list if this leads to
969+ // an empty diagnostic list for said files
970+ for diags in self.editor.diagnostics.values_mut() {
971+ diags.retain(|(_, lsp_id)| *lsp_id != server_id);
972+ }
980973
981− for url in urls {
982− self.editor.diagnostics.remove(&url);
974+ self.editor.diagnostics.retain(|_, diags| !diags.is_empty());
975+
976+ // Clear any diagnostics for documents with this server open.
977+ for doc in self.editor.documents_mut() {
978+ doc.clear_diagnostics(server_id);
983979 }
984980
985981 // Remove the language server from the registry.