Update display map snapshots when diagnostics are updated

This is similar to what we do when we receive new parse trees from
tree-sitter.
This commit is contained in:
Antonio Scandurra 2021-10-27 12:39:11 +02:00
parent a7a73a5b0b
commit bc076c1cc1
2 changed files with 14 additions and 1 deletions

View file

@ -63,6 +63,7 @@ pub struct Buffer {
parsing_in_background: bool,
parse_count: usize,
diagnostics: AnchorRangeMultimap<(DiagnosticSeverity, String)>,
diagnostics_update_count: usize,
language_server: Option<LanguageServerState>,
#[cfg(test)]
operations: Vec<Operation>,
@ -288,6 +289,7 @@ impl Buffer {
pending_autoindent: Default::default(),
language: None,
diagnostics: Default::default(),
diagnostics_update_count: 0,
language_server: None,
#[cfg(test)]
operations: Default::default(),
@ -686,6 +688,7 @@ impl Buffer {
}
}
self.diagnostics_update_count += 1;
cx.notify();
Ok(())
}
@ -705,6 +708,10 @@ impl Buffer {
})
}
pub fn diagnostics_update_count(&self) -> usize {
self.diagnostics_update_count
}
fn request_autoindent(&mut self, cx: &mut ModelContext<Self>) {
if let Some(indent_columns) = self.compute_autoindents() {
let indent_columns = cx.background().spawn(indent_columns);
@ -1335,6 +1342,7 @@ impl Clone for Buffer {
autoindent_requests: Default::default(),
pending_autoindent: Default::default(),
diagnostics: self.diagnostics.clone(),
diagnostics_update_count: self.diagnostics_update_count,
language_server: None,
#[cfg(test)]
operations: self.operations.clone(),