on master help sign in
Update diagnostics correctly on LSP exit (#7111)
8e2660bPoliorcetics
helix-term/src/application.rs+11−15
@@ -964,22 +964,18 @@ impl Application {
964 Notification::Exit => {
964 Notification::Exit => {
965 self.editor.set_status("Language server exited");
965 self.editor.set_status("Language server exited");
966
966
967− // Clear any diagnostics for documents with this server open.
967+ // LSPs may produce diagnostics for files that haven't been opened in helix,
968− let urls: Vec<_> = self
968+ // we need to clear those and remove the entries from the list if this leads to
969− .editor
969+ // an empty diagnostic list for said files
970− .documents_mut()
970+ for diags in self.editor.diagnostics.values_mut() {
971− .filter_map(|doc| {
971+ diags.retain(|(_, lsp_id)| *lsp_id != server_id);
972− if doc.supports_language_server(server_id) {
973− doc.clear_diagnostics(server_id);
974− doc.url()
975− } else {
976− None
977− }
978− })
972+ }
979− .collect();
980
973
981− for url in urls {
974+ self.editor.diagnostics.retain(|_, diags| !diags.is_empty());
982− self.editor.diagnostics.remove(&url);
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);
983 }
979 }
984
980
985 // Remove the language server from the registry.
981 // Remove the language server from the registry.
helix-term/src/ui/statusline.rs+1−1
@@ -275,7 +275,7 @@ where
275 });
275 });
276
276
277 if warnings > 0 || errors > 0 {
277 if warnings > 0 || errors > 0 {
278− write(context, format!(" {} ", "W"), None);
278+ write(context, " W ".into(), None);
279 }
279 }
280
280
281 if warnings > 0 {
281 if warnings > 0 {