Merge pull request #1010 from zed-industries/fix-stale-wrap-snapshot
Bump `FoldSnapshot` version if excerpt gets edited outside of its bounds
This commit is contained in:
@@ -271,7 +271,8 @@ impl FoldMap {
|
||||
) -> Vec<FoldEdit> {
|
||||
if buffer_edits.is_empty() {
|
||||
let mut buffer = self.buffer.lock();
|
||||
if buffer.parse_count() != new_buffer.parse_count()
|
||||
if buffer.edit_count() != new_buffer.edit_count()
|
||||
|| buffer.parse_count() != new_buffer.parse_count()
|
||||
|| buffer.diagnostics_update_count() != new_buffer.diagnostics_update_count()
|
||||
|| buffer.trailing_excerpt_update_count()
|
||||
!= new_buffer.trailing_excerpt_update_count()
|
||||
|
||||
@@ -93,6 +93,7 @@ pub struct MultiBufferSnapshot {
|
||||
parse_count: usize,
|
||||
diagnostics_update_count: usize,
|
||||
trailing_excerpt_update_count: usize,
|
||||
edit_count: usize,
|
||||
is_dirty: bool,
|
||||
has_conflict: bool,
|
||||
}
|
||||
@@ -1151,6 +1152,7 @@ impl MultiBuffer {
|
||||
let mut diagnostics_updated = false;
|
||||
let mut is_dirty = false;
|
||||
let mut has_conflict = false;
|
||||
let mut edited = false;
|
||||
let mut buffers = self.buffers.borrow_mut();
|
||||
for buffer_state in buffers.values_mut() {
|
||||
let buffer = buffer_state.buffer.read(cx);
|
||||
@@ -1186,11 +1188,15 @@ impl MultiBuffer {
|
||||
);
|
||||
}
|
||||
|
||||
edited |= buffer_edited;
|
||||
reparsed |= buffer_reparsed;
|
||||
diagnostics_updated |= buffer_diagnostics_updated;
|
||||
is_dirty |= buffer.is_dirty();
|
||||
has_conflict |= buffer.has_conflict();
|
||||
}
|
||||
if edited {
|
||||
snapshot.edit_count += 1;
|
||||
}
|
||||
if reparsed {
|
||||
snapshot.parse_count += 1;
|
||||
}
|
||||
@@ -2172,6 +2178,10 @@ impl MultiBufferSnapshot {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn edit_count(&self) -> usize {
|
||||
self.edit_count
|
||||
}
|
||||
|
||||
pub fn parse_count(&self) -> usize {
|
||||
self.parse_count
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user