mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 02:20:10 +00:00
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:
parent
a7a73a5b0b
commit
bc076c1cc1
2 changed files with 14 additions and 1 deletions
|
@ -204,6 +204,7 @@ pub struct FoldMap {
|
||||||
struct SyncState {
|
struct SyncState {
|
||||||
version: clock::Global,
|
version: clock::Global,
|
||||||
parse_count: usize,
|
parse_count: usize,
|
||||||
|
diagnostics_update_count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FoldMap {
|
impl FoldMap {
|
||||||
|
@ -225,6 +226,7 @@ impl FoldMap {
|
||||||
last_sync: Mutex::new(SyncState {
|
last_sync: Mutex::new(SyncState {
|
||||||
version: buffer.version(),
|
version: buffer.version(),
|
||||||
parse_count: buffer.parse_count(),
|
parse_count: buffer.parse_count(),
|
||||||
|
diagnostics_update_count: buffer.diagnostics_update_count(),
|
||||||
}),
|
}),
|
||||||
version: AtomicUsize::new(0),
|
version: AtomicUsize::new(0),
|
||||||
};
|
};
|
||||||
|
@ -256,6 +258,7 @@ impl FoldMap {
|
||||||
SyncState {
|
SyncState {
|
||||||
version: buffer.version(),
|
version: buffer.version(),
|
||||||
parse_count: buffer.parse_count(),
|
parse_count: buffer.parse_count(),
|
||||||
|
diagnostics_update_count: buffer.diagnostics_update_count(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let edits = buffer
|
let edits = buffer
|
||||||
|
@ -263,7 +266,9 @@ impl FoldMap {
|
||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
if edits.is_empty() {
|
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);
|
self.version.fetch_add(1, SeqCst);
|
||||||
}
|
}
|
||||||
Vec::new()
|
Vec::new()
|
||||||
|
|
|
@ -63,6 +63,7 @@ pub struct Buffer {
|
||||||
parsing_in_background: bool,
|
parsing_in_background: bool,
|
||||||
parse_count: usize,
|
parse_count: usize,
|
||||||
diagnostics: AnchorRangeMultimap<(DiagnosticSeverity, String)>,
|
diagnostics: AnchorRangeMultimap<(DiagnosticSeverity, String)>,
|
||||||
|
diagnostics_update_count: usize,
|
||||||
language_server: Option<LanguageServerState>,
|
language_server: Option<LanguageServerState>,
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
operations: Vec<Operation>,
|
operations: Vec<Operation>,
|
||||||
|
@ -288,6 +289,7 @@ impl Buffer {
|
||||||
pending_autoindent: Default::default(),
|
pending_autoindent: Default::default(),
|
||||||
language: None,
|
language: None,
|
||||||
diagnostics: Default::default(),
|
diagnostics: Default::default(),
|
||||||
|
diagnostics_update_count: 0,
|
||||||
language_server: None,
|
language_server: None,
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
operations: Default::default(),
|
operations: Default::default(),
|
||||||
|
@ -686,6 +688,7 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.diagnostics_update_count += 1;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
Ok(())
|
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>) {
|
fn request_autoindent(&mut self, cx: &mut ModelContext<Self>) {
|
||||||
if let Some(indent_columns) = self.compute_autoindents() {
|
if let Some(indent_columns) = self.compute_autoindents() {
|
||||||
let indent_columns = cx.background().spawn(indent_columns);
|
let indent_columns = cx.background().spawn(indent_columns);
|
||||||
|
@ -1335,6 +1342,7 @@ impl Clone for Buffer {
|
||||||
autoindent_requests: Default::default(),
|
autoindent_requests: Default::default(),
|
||||||
pending_autoindent: Default::default(),
|
pending_autoindent: Default::default(),
|
||||||
diagnostics: self.diagnostics.clone(),
|
diagnostics: self.diagnostics.clone(),
|
||||||
|
diagnostics_update_count: self.diagnostics_update_count,
|
||||||
language_server: None,
|
language_server: None,
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
operations: self.operations.clone(),
|
operations: self.operations.clone(),
|
||||||
|
|
Loading…
Reference in a new issue