Don't ignore new tab snapshot in WrapMap
if only tab size changed
This commit is contained in:
parent
385d214b47
commit
1e94eb74f4
2 changed files with 11 additions and 7 deletions
|
@ -16,6 +16,7 @@ impl TabMap {
|
|||
let snapshot = TabSnapshot {
|
||||
fold_snapshot: input,
|
||||
tab_size,
|
||||
version: 0,
|
||||
};
|
||||
(Self(Mutex::new(snapshot.clone())), snapshot)
|
||||
}
|
||||
|
@ -27,12 +28,14 @@ impl TabMap {
|
|||
tab_size: NonZeroU32,
|
||||
) -> (TabSnapshot, Vec<TabEdit>) {
|
||||
let mut old_snapshot = self.0.lock();
|
||||
let new_snapshot = TabSnapshot {
|
||||
let mut new_snapshot = TabSnapshot {
|
||||
fold_snapshot,
|
||||
tab_size,
|
||||
version: old_snapshot.version,
|
||||
};
|
||||
|
||||
if old_snapshot.tab_size != new_snapshot.tab_size {
|
||||
new_snapshot.version += 1;
|
||||
let edits = vec![TabEdit {
|
||||
old: TabPoint::zero()..old_snapshot.max_point(),
|
||||
new: TabPoint::zero()..new_snapshot.max_point(),
|
||||
|
@ -40,6 +43,10 @@ impl TabMap {
|
|||
return (new_snapshot, edits);
|
||||
}
|
||||
|
||||
if old_snapshot.fold_snapshot.version != new_snapshot.fold_snapshot.version {
|
||||
new_snapshot.version += 1;
|
||||
}
|
||||
|
||||
let old_max_offset = old_snapshot.fold_snapshot.len();
|
||||
let mut tab_edits = Vec::with_capacity(fold_edits.len());
|
||||
for fold_edit in &mut fold_edits {
|
||||
|
@ -97,6 +104,7 @@ impl TabMap {
|
|||
pub struct TabSnapshot {
|
||||
pub fold_snapshot: FoldSnapshot,
|
||||
pub tab_size: NonZeroU32,
|
||||
pub version: usize,
|
||||
}
|
||||
|
||||
impl TabSnapshot {
|
||||
|
@ -168,10 +176,6 @@ impl TabSnapshot {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn version(&self) -> usize {
|
||||
self.fold_snapshot.version
|
||||
}
|
||||
|
||||
pub fn chunks<'a>(
|
||||
&'a self,
|
||||
range: Range<TabPoint>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue