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 {
|
let snapshot = TabSnapshot {
|
||||||
fold_snapshot: input,
|
fold_snapshot: input,
|
||||||
tab_size,
|
tab_size,
|
||||||
|
version: 0,
|
||||||
};
|
};
|
||||||
(Self(Mutex::new(snapshot.clone())), snapshot)
|
(Self(Mutex::new(snapshot.clone())), snapshot)
|
||||||
}
|
}
|
||||||
|
@ -27,12 +28,14 @@ impl TabMap {
|
||||||
tab_size: NonZeroU32,
|
tab_size: NonZeroU32,
|
||||||
) -> (TabSnapshot, Vec<TabEdit>) {
|
) -> (TabSnapshot, Vec<TabEdit>) {
|
||||||
let mut old_snapshot = self.0.lock();
|
let mut old_snapshot = self.0.lock();
|
||||||
let new_snapshot = TabSnapshot {
|
let mut new_snapshot = TabSnapshot {
|
||||||
fold_snapshot,
|
fold_snapshot,
|
||||||
tab_size,
|
tab_size,
|
||||||
|
version: old_snapshot.version,
|
||||||
};
|
};
|
||||||
|
|
||||||
if old_snapshot.tab_size != new_snapshot.tab_size {
|
if old_snapshot.tab_size != new_snapshot.tab_size {
|
||||||
|
new_snapshot.version += 1;
|
||||||
let edits = vec![TabEdit {
|
let edits = vec![TabEdit {
|
||||||
old: TabPoint::zero()..old_snapshot.max_point(),
|
old: TabPoint::zero()..old_snapshot.max_point(),
|
||||||
new: TabPoint::zero()..new_snapshot.max_point(),
|
new: TabPoint::zero()..new_snapshot.max_point(),
|
||||||
|
@ -40,6 +43,10 @@ impl TabMap {
|
||||||
return (new_snapshot, edits);
|
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 old_max_offset = old_snapshot.fold_snapshot.len();
|
||||||
let mut tab_edits = Vec::with_capacity(fold_edits.len());
|
let mut tab_edits = Vec::with_capacity(fold_edits.len());
|
||||||
for fold_edit in &mut fold_edits {
|
for fold_edit in &mut fold_edits {
|
||||||
|
@ -97,6 +104,7 @@ impl TabMap {
|
||||||
pub struct TabSnapshot {
|
pub struct TabSnapshot {
|
||||||
pub fold_snapshot: FoldSnapshot,
|
pub fold_snapshot: FoldSnapshot,
|
||||||
pub tab_size: NonZeroU32,
|
pub tab_size: NonZeroU32,
|
||||||
|
pub version: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TabSnapshot {
|
impl TabSnapshot {
|
||||||
|
@ -168,10 +176,6 @@ impl TabSnapshot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn version(&self) -> usize {
|
|
||||||
self.fold_snapshot.version
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chunks<'a>(
|
pub fn chunks<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
range: Range<TabPoint>,
|
range: Range<TabPoint>,
|
||||||
|
|
|
@ -220,7 +220,7 @@ impl WrapMap {
|
||||||
if !self.snapshot.interpolated {
|
if !self.snapshot.interpolated {
|
||||||
let mut to_remove_len = 0;
|
let mut to_remove_len = 0;
|
||||||
for (tab_snapshot, _) in &self.pending_edits {
|
for (tab_snapshot, _) in &self.pending_edits {
|
||||||
if tab_snapshot.version() <= self.snapshot.tab_snapshot.version() {
|
if tab_snapshot.version <= self.snapshot.tab_snapshot.version {
|
||||||
to_remove_len += 1;
|
to_remove_len += 1;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -282,7 +282,7 @@ impl WrapMap {
|
||||||
let was_interpolated = self.snapshot.interpolated;
|
let was_interpolated = self.snapshot.interpolated;
|
||||||
let mut to_remove_len = 0;
|
let mut to_remove_len = 0;
|
||||||
for (tab_snapshot, edits) in &self.pending_edits {
|
for (tab_snapshot, edits) in &self.pending_edits {
|
||||||
if tab_snapshot.version() <= self.snapshot.tab_snapshot.version() {
|
if tab_snapshot.version <= self.snapshot.tab_snapshot.version {
|
||||||
to_remove_len += 1;
|
to_remove_len += 1;
|
||||||
} else {
|
} else {
|
||||||
let interpolated_edits = self.snapshot.interpolate(tab_snapshot.clone(), &edits);
|
let interpolated_edits = self.snapshot.interpolate(tab_snapshot.clone(), &edits);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue