diff options
author | Poliorcetics | 2023-05-23 10:33:01 +0000 |
---|---|---|
committer | GitHub | 2023-05-23 10:33:01 +0000 |
commit | 8e2660b5cc86266f90926aefe1470f48c801f8bc (patch) | |
tree | 783197560853e4ddd63d660b33bcc99790c3ea88 | |
parent | 6043c3c3dbef8c40bdd768bb03060b7e376b7aea (diff) |
Update diagnostics correctly on LSP exit (#7111)
* chore: avoid format! call with argument when useless
* feat: also clear diagnostics for unopened documents when exiting an LSP
* feat: we already worked on `self.editor.diagnostics` no need to redo the checks
-rw-r--r-- | helix-term/src/application.rs | 26 | ||||
-rw-r--r-- | helix-term/src/ui/statusline.rs | 2 |
2 files changed, 12 insertions, 16 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 40c6d8c6..0ea31413 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -964,22 +964,18 @@ impl Application { Notification::Exit => { self.editor.set_status("Language server exited"); - // Clear any diagnostics for documents with this server open. - let urls: Vec<_> = self - .editor - .documents_mut() - .filter_map(|doc| { - if doc.supports_language_server(server_id) { - doc.clear_diagnostics(server_id); - doc.url() - } else { - None - } - }) - .collect(); + // LSPs may produce diagnostics for files that haven't been opened in helix, + // we need to clear those and remove the entries from the list if this leads to + // an empty diagnostic list for said files + for diags in self.editor.diagnostics.values_mut() { + diags.retain(|(_, lsp_id)| *lsp_id != server_id); + } - for url in urls { - self.editor.diagnostics.remove(&url); + self.editor.diagnostics.retain(|_, diags| !diags.is_empty()); + + // Clear any diagnostics for documents with this server open. + for doc in self.editor.documents_mut() { + doc.clear_diagnostics(server_id); } // Remove the language server from the registry. diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 4aa64634..dbf5ac31 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -275,7 +275,7 @@ where }); if warnings > 0 || errors > 0 { - write(context, format!(" {} ", "W"), None); + write(context, " W ".into(), None); } if warnings > 0 { |