Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update diagnostics correctly on LSP exit #7111

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion helix-term/src/ui/statusline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ where
});

if warnings > 0 || errors > 0 {
write(context, format!(" {} ", "W"), None);
write(context, " W ".into(), None);
}

if warnings > 0 {
Expand Down