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

Issue diagnostics, even if empty. #1478

Merged
merged 1 commit into from
Jul 27, 2023
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
11 changes: 5 additions & 6 deletions lsp/nls/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ pub fn handle_save(server: &mut Server, params: DidChangeTextDocumentParams) ->
parse_and_typecheck(server, file_id)?;

for f in &invalid {
if let Err(e) = typecheck(server, *f) {
server.issue_diagnostics(*f, e);
}
let errors = typecheck(server, *f).err().unwrap_or_default();
server.issue_diagnostics(*f, errors);
}
Trace::reply(id);
Ok(())
Expand Down Expand Up @@ -105,15 +104,15 @@ fn parse_and_typecheck(server: &mut Server, file_id: FileId) -> Result<()> {
Ok(errs) => (errs.inner(), false),
Err(errs) => (errs, true),
};
let diags = parse_errs.into_diagnostics(server.cache.files_mut(), None);
server.issue_diagnostics(file_id, diags);
let mut diags = parse_errs.into_diagnostics(server.cache.files_mut(), None);

if !fatal {
trace!("Parsed, checking types");
if let Err(e) = typecheck(server, file_id) {
server.issue_diagnostics(file_id, e);
diags.extend_from_slice(&e);
}
}
server.issue_diagnostics(file_id, diags);

Ok(())
}
20 changes: 10 additions & 10 deletions lsp/nls/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,15 @@ impl Server {
.flat_map(|d| lsp_types::Diagnostic::from_codespan(d, self.cache.files_mut()))
.collect();

if !diagnostics.is_empty() {
self.notify(lsp_server::Notification::new(
"textDocument/publishDiagnostics".into(),
PublishDiagnosticsParams {
uri,
diagnostics,
version: None,
},
));
}
// Issue diagnostics even if they're empty (empty diagnostics are how the editor knows
// that any previous errors were resolved).
self.notify(lsp_server::Notification::new(
"textDocument/publishDiagnostics".into(),
PublishDiagnosticsParams {
uri,
diagnostics,
version: None,
},
));
}
}