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

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