1
1
mirror of https://github.com/oxalica/nil.git synced 2024-10-27 04:19:40 +03:00

Fix panic

This commit is contained in:
oxalica 2022-08-09 07:32:09 +08:00
parent 11a690bb73
commit f2006b83d1

View File

@ -104,16 +104,17 @@ impl State {
// Currently we push down changes immediately.
assert_eq!(change.file_changes.len(), 1);
let (file, text) = &change.file_changes[0];
let line_map = vfs.file_line_map(*file).unwrap();
let diagnostics = text
.as_ref()
.and_then(|_| self.host.snapshot().diagnostics(*file).ok())
.map(|diags| {
diags
let diagnostics = vfs
.file_line_map(*file)
.and_then(|line_map| {
let _ = text.as_deref()?;
let diags = self.host.snapshot().diagnostics(*file).ok()?;
let diags = diags
.into_iter()
.take(MAX_DIAGNOSTICS_CNT)
.filter_map(|diag| convert::to_diagnostic(line_map, diag))
.collect::<Vec<_>>()
.collect::<Vec<_>>();
Some(diags)
})
.unwrap_or_default();
self.send_notification::<notif::PublishDiagnostics>(PublishDiagnosticsParams {