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:
@@ -204,6 +204,7 @@ pub struct FoldMap {
|
||||
struct SyncState {
|
||||
version: clock::Global,
|
||||
parse_count: usize,
|
||||
diagnostics_update_count: usize,
|
||||
}
|
||||
|
||||
impl FoldMap {
|
||||
@@ -225,6 +226,7 @@ impl FoldMap {
|
||||
last_sync: Mutex::new(SyncState {
|
||||
version: buffer.version(),
|
||||
parse_count: buffer.parse_count(),
|
||||
diagnostics_update_count: buffer.diagnostics_update_count(),
|
||||
}),
|
||||
version: AtomicUsize::new(0),
|
||||
};
|
||||
@@ -256,6 +258,7 @@ impl FoldMap {
|
||||
SyncState {
|
||||
version: buffer.version(),
|
||||
parse_count: buffer.parse_count(),
|
||||
diagnostics_update_count: buffer.diagnostics_update_count(),
|
||||
},
|
||||
);
|
||||
let edits = buffer
|
||||
@@ -263,7 +266,9 @@ impl FoldMap {
|
||||
.map(Into::into)
|
||||
.collect::<Vec<_>>();
|
||||
if edits.is_empty() {
|
||||
if last_sync.parse_count != buffer.parse_count() {
|
||||
if last_sync.parse_count != buffer.parse_count()
|
||||
|| last_sync.diagnostics_update_count != buffer.diagnostics_update_count()
|
||||
{
|
||||
self.version.fetch_add(1, SeqCst);
|
||||
}
|
||||
Vec::new()
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user