6656: Coalesce flycheck events r=matklad a=jonas-schievink



Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
bors[bot] 2020-11-28 13:56:28 +00:00 committed by GitHub
commit fe2ac4480b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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();