Coalesce flycheck events

This commit is contained in:
Jonas Schievink 2020-11-27 22:52:22 +01:00
parent 59c4975b54
commit f52abbe62d

View file

@ -289,9 +289,13 @@ impl GlobalState {
}
}
}
Event::Flycheck(task) => match task {
Event::Flycheck(mut task) => {
let _p = profile::span("GlobalState::handle_event/flycheck");
loop {
match task {
flycheck::Message::AddDiagnostic { workspace_root, diagnostic } => {
let diagnostics = crate::diagnostics::to_proto::map_rust_diagnostic_to_lsp(
let diagnostics =
crate::diagnostics::to_proto::map_rust_diagnostic_to_lsp(
&self.config.diagnostics_map,
&diagnostic,
&workspace_root,
@ -304,7 +308,10 @@ impl GlobalState {
diag.fixes,
),
Err(err) => {
log::error!("File with cargo diagnostic not found in VFS: {}", err);
log::error!(
"File with cargo diagnostic not found in VFS: {}",
err
);
}
};
}
@ -337,7 +344,14 @@ impl GlobalState {
};
self.report_progress(&title, state, message, None);
}
},
}
// Coalesce many flycheck updates into a single loop turn
task = match self.flycheck_receiver.try_recv() {
Ok(task) => task,
Err(_) => break,
}
}
}
}
let state_changed = self.process_changes();