Update FoldMap snapshot versions when only the parse tree changes

even if the buffer's text has not changed

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-09-06 11:57:55 -07:00
co-authored by Nathan Sobo
parent 94959d18c4
commit 11b8577d1b
2 changed files with 30 additions and 13 deletions
+4 -4
View File
@@ -201,7 +201,7 @@ pub struct FoldMap {
#[derive(Clone)]
struct SyncState {
version: time::Global,
is_parsing: bool,
parse_count: usize,
}
impl FoldMap {
@@ -222,7 +222,7 @@ impl FoldMap {
)),
last_sync: Mutex::new(SyncState {
version: buffer.version(),
is_parsing: buffer.is_parsing(),
parse_count: buffer.parse_count(),
}),
version: AtomicUsize::new(0),
};
@@ -253,7 +253,7 @@ impl FoldMap {
&mut *self.last_sync.lock(),
SyncState {
version: buffer.version(),
is_parsing: buffer.is_parsing(),
parse_count: buffer.parse_count(),
},
);
let edits = buffer
@@ -261,7 +261,7 @@ impl FoldMap {
.map(Into::into)
.collect::<Vec<_>>();
if edits.is_empty() {
if last_sync.is_parsing != buffer.is_parsing() {
if last_sync.parse_count != buffer.parse_count() {
self.version.fetch_add(1, SeqCst);
}
Vec::new()