sum_tree: Store context on cursor (#34904)
This gets rid of the need to pass context to all cursor functions. In practice context is always immutable when interacting with cursors. A nicety of this is in the follow-up PR we will be able to implement Iterator for all Cursors/filter cursors (hell, we may be able to get rid of filter cursor altogether, as it is just a custom `filter` impl on iterator trait). Release Notes: - N/A
This commit is contained in:
parent
fa3e1ccc37
commit
64d0fec699
23 changed files with 749 additions and 876 deletions
|
@ -524,10 +524,10 @@ impl BlockMap {
|
|||
// * Isomorphic transforms that end *at* the start of the edit
|
||||
// * Below blocks that end at the start of the edit
|
||||
// However, if we hit a replace block that ends at the start of the edit we want to reconstruct it.
|
||||
new_transforms.append(cursor.slice(&old_start, Bias::Left, &()), &());
|
||||
new_transforms.append(cursor.slice(&old_start, Bias::Left), &());
|
||||
if let Some(transform) = cursor.item() {
|
||||
if transform.summary.input_rows > 0
|
||||
&& cursor.end(&()) == old_start
|
||||
&& cursor.end() == old_start
|
||||
&& transform
|
||||
.block
|
||||
.as_ref()
|
||||
|
@ -535,13 +535,13 @@ impl BlockMap {
|
|||
{
|
||||
// Preserve the transform (push and next)
|
||||
new_transforms.push(transform.clone(), &());
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
|
||||
// Preserve below blocks at end of edit
|
||||
while let Some(transform) = cursor.item() {
|
||||
if transform.block.as_ref().map_or(false, |b| b.place_below()) {
|
||||
new_transforms.push(transform.clone(), &());
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -579,8 +579,8 @@ impl BlockMap {
|
|||
let mut new_end = WrapRow(edit.new.end);
|
||||
loop {
|
||||
// Seek to the transform starting at or after the end of the edit
|
||||
cursor.seek(&old_end, Bias::Left, &());
|
||||
cursor.next(&());
|
||||
cursor.seek(&old_end, Bias::Left);
|
||||
cursor.next();
|
||||
|
||||
// Extend edit to the end of the discarded transform so it is reconstructed in full
|
||||
let transform_rows_after_edit = cursor.start().0 - old_end.0;
|
||||
|
@ -592,8 +592,8 @@ impl BlockMap {
|
|||
if next_edit.old.start <= cursor.start().0 {
|
||||
old_end = WrapRow(next_edit.old.end);
|
||||
new_end = WrapRow(next_edit.new.end);
|
||||
cursor.seek(&old_end, Bias::Left, &());
|
||||
cursor.next(&());
|
||||
cursor.seek(&old_end, Bias::Left);
|
||||
cursor.next();
|
||||
edits.next();
|
||||
} else {
|
||||
break;
|
||||
|
@ -608,7 +608,7 @@ impl BlockMap {
|
|||
// Discard below blocks at the end of the edit. They'll be reconstructed.
|
||||
while let Some(transform) = cursor.item() {
|
||||
if transform.block.as_ref().map_or(false, |b| b.place_below()) {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -720,7 +720,7 @@ impl BlockMap {
|
|||
push_isomorphic(&mut new_transforms, rows_after_last_block, wrap_snapshot);
|
||||
}
|
||||
|
||||
new_transforms.append(cursor.suffix(&()), &());
|
||||
new_transforms.append(cursor.suffix(), &());
|
||||
debug_assert_eq!(
|
||||
new_transforms.summary().input_rows,
|
||||
wrap_snapshot.max_point().row() + 1
|
||||
|
@ -971,7 +971,7 @@ impl BlockMapReader<'_> {
|
|||
);
|
||||
|
||||
let mut cursor = self.transforms.cursor::<(WrapRow, BlockRow)>(&());
|
||||
cursor.seek(&start_wrap_row, Bias::Left, &());
|
||||
cursor.seek(&start_wrap_row, Bias::Left);
|
||||
while let Some(transform) = cursor.item() {
|
||||
if cursor.start().0 > end_wrap_row {
|
||||
break;
|
||||
|
@ -982,7 +982,7 @@ impl BlockMapReader<'_> {
|
|||
return Some(cursor.start().1);
|
||||
}
|
||||
}
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
|
||||
None
|
||||
|
@ -1293,7 +1293,7 @@ impl BlockSnapshot {
|
|||
let max_output_row = cmp::min(rows.end, self.transforms.summary().output_rows);
|
||||
|
||||
let mut cursor = self.transforms.cursor::<(BlockRow, WrapRow)>(&());
|
||||
cursor.seek(&BlockRow(rows.start), Bias::Right, &());
|
||||
cursor.seek(&BlockRow(rows.start), Bias::Right);
|
||||
let transform_output_start = cursor.start().0.0;
|
||||
let transform_input_start = cursor.start().1.0;
|
||||
|
||||
|
@ -1325,7 +1325,7 @@ impl BlockSnapshot {
|
|||
|
||||
pub(super) fn row_infos(&self, start_row: BlockRow) -> BlockRows<'_> {
|
||||
let mut cursor = self.transforms.cursor::<(BlockRow, WrapRow)>(&());
|
||||
cursor.seek(&start_row, Bias::Right, &());
|
||||
cursor.seek(&start_row, Bias::Right);
|
||||
let (output_start, input_start) = cursor.start();
|
||||
let overshoot = if cursor
|
||||
.item()
|
||||
|
@ -1346,9 +1346,9 @@ impl BlockSnapshot {
|
|||
|
||||
pub fn blocks_in_range(&self, rows: Range<u32>) -> impl Iterator<Item = (u32, &Block)> {
|
||||
let mut cursor = self.transforms.cursor::<BlockRow>(&());
|
||||
cursor.seek(&BlockRow(rows.start), Bias::Left, &());
|
||||
while cursor.start().0 < rows.start && cursor.end(&()).0 <= rows.start {
|
||||
cursor.next(&());
|
||||
cursor.seek(&BlockRow(rows.start), Bias::Left);
|
||||
while cursor.start().0 < rows.start && cursor.end().0 <= rows.start {
|
||||
cursor.next();
|
||||
}
|
||||
|
||||
std::iter::from_fn(move || {
|
||||
|
@ -1364,10 +1364,10 @@ impl BlockSnapshot {
|
|||
break;
|
||||
}
|
||||
if let Some(block) = &transform.block {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
return Some((start_row, block));
|
||||
} else {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
None
|
||||
|
@ -1377,7 +1377,7 @@ impl BlockSnapshot {
|
|||
pub fn sticky_header_excerpt(&self, position: f32) -> Option<StickyHeaderExcerpt<'_>> {
|
||||
let top_row = position as u32;
|
||||
let mut cursor = self.transforms.cursor::<BlockRow>(&());
|
||||
cursor.seek(&BlockRow(top_row), Bias::Right, &());
|
||||
cursor.seek(&BlockRow(top_row), Bias::Right);
|
||||
|
||||
while let Some(transform) = cursor.item() {
|
||||
match &transform.block {
|
||||
|
@ -1386,7 +1386,7 @@ impl BlockSnapshot {
|
|||
}
|
||||
Some(block) if block.is_buffer_header() => return None,
|
||||
_ => {
|
||||
cursor.prev(&());
|
||||
cursor.prev();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -1414,7 +1414,7 @@ impl BlockSnapshot {
|
|||
let wrap_row = WrapRow(wrap_point.row());
|
||||
|
||||
let mut cursor = self.transforms.cursor::<WrapRow>(&());
|
||||
cursor.seek(&wrap_row, Bias::Left, &());
|
||||
cursor.seek(&wrap_row, Bias::Left);
|
||||
|
||||
while let Some(transform) = cursor.item() {
|
||||
if let Some(block) = transform.block.as_ref() {
|
||||
|
@ -1425,7 +1425,7 @@ impl BlockSnapshot {
|
|||
break;
|
||||
}
|
||||
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
|
||||
None
|
||||
|
@ -1442,7 +1442,7 @@ impl BlockSnapshot {
|
|||
|
||||
pub fn longest_row_in_range(&self, range: Range<BlockRow>) -> BlockRow {
|
||||
let mut cursor = self.transforms.cursor::<(BlockRow, WrapRow)>(&());
|
||||
cursor.seek(&range.start, Bias::Right, &());
|
||||
cursor.seek(&range.start, Bias::Right);
|
||||
|
||||
let mut longest_row = range.start;
|
||||
let mut longest_row_chars = 0;
|
||||
|
@ -1453,7 +1453,7 @@ impl BlockSnapshot {
|
|||
let wrap_start_row = input_start.0 + overshoot;
|
||||
let wrap_end_row = cmp::min(
|
||||
input_start.0 + (range.end.0 - output_start.0),
|
||||
cursor.end(&()).1.0,
|
||||
cursor.end().1.0,
|
||||
);
|
||||
let summary = self
|
||||
.wrap_snapshot
|
||||
|
@ -1461,12 +1461,12 @@ impl BlockSnapshot {
|
|||
longest_row = BlockRow(range.start.0 + summary.longest_row);
|
||||
longest_row_chars = summary.longest_row_chars;
|
||||
}
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
|
||||
let cursor_start_row = cursor.start().0;
|
||||
if range.end > cursor_start_row {
|
||||
let summary = cursor.summary::<_, TransformSummary>(&range.end, Bias::Right, &());
|
||||
let summary = cursor.summary::<_, TransformSummary>(&range.end, Bias::Right);
|
||||
if summary.longest_row_chars > longest_row_chars {
|
||||
longest_row = BlockRow(cursor_start_row.0 + summary.longest_row);
|
||||
longest_row_chars = summary.longest_row_chars;
|
||||
|
@ -1493,7 +1493,7 @@ impl BlockSnapshot {
|
|||
|
||||
pub(super) fn line_len(&self, row: BlockRow) -> u32 {
|
||||
let mut cursor = self.transforms.cursor::<(BlockRow, WrapRow)>(&());
|
||||
cursor.seek(&BlockRow(row.0), Bias::Right, &());
|
||||
cursor.seek(&BlockRow(row.0), Bias::Right);
|
||||
if let Some(transform) = cursor.item() {
|
||||
let (output_start, input_start) = cursor.start();
|
||||
let overshoot = row.0 - output_start.0;
|
||||
|
@ -1511,13 +1511,13 @@ impl BlockSnapshot {
|
|||
|
||||
pub(super) fn is_block_line(&self, row: BlockRow) -> bool {
|
||||
let mut cursor = self.transforms.cursor::<(BlockRow, WrapRow)>(&());
|
||||
cursor.seek(&row, Bias::Right, &());
|
||||
cursor.seek(&row, Bias::Right);
|
||||
cursor.item().map_or(false, |t| t.block.is_some())
|
||||
}
|
||||
|
||||
pub(super) fn is_folded_buffer_header(&self, row: BlockRow) -> bool {
|
||||
let mut cursor = self.transforms.cursor::<(BlockRow, WrapRow)>(&());
|
||||
cursor.seek(&row, Bias::Right, &());
|
||||
cursor.seek(&row, Bias::Right);
|
||||
let Some(transform) = cursor.item() else {
|
||||
return false;
|
||||
};
|
||||
|
@ -1529,7 +1529,7 @@ impl BlockSnapshot {
|
|||
.wrap_snapshot
|
||||
.make_wrap_point(Point::new(row.0, 0), Bias::Left);
|
||||
let mut cursor = self.transforms.cursor::<(WrapRow, BlockRow)>(&());
|
||||
cursor.seek(&WrapRow(wrap_point.row()), Bias::Right, &());
|
||||
cursor.seek(&WrapRow(wrap_point.row()), Bias::Right);
|
||||
cursor.item().map_or(false, |transform| {
|
||||
transform
|
||||
.block
|
||||
|
@ -1540,17 +1540,17 @@ impl BlockSnapshot {
|
|||
|
||||
pub fn clip_point(&self, point: BlockPoint, bias: Bias) -> BlockPoint {
|
||||
let mut cursor = self.transforms.cursor::<(BlockRow, WrapRow)>(&());
|
||||
cursor.seek(&BlockRow(point.row), Bias::Right, &());
|
||||
cursor.seek(&BlockRow(point.row), Bias::Right);
|
||||
|
||||
let max_input_row = WrapRow(self.transforms.summary().input_rows);
|
||||
let mut search_left =
|
||||
(bias == Bias::Left && cursor.start().1.0 > 0) || cursor.end(&()).1 == max_input_row;
|
||||
(bias == Bias::Left && cursor.start().1.0 > 0) || cursor.end().1 == max_input_row;
|
||||
let mut reversed = false;
|
||||
|
||||
loop {
|
||||
if let Some(transform) = cursor.item() {
|
||||
let (output_start_row, input_start_row) = cursor.start();
|
||||
let (output_end_row, input_end_row) = cursor.end(&());
|
||||
let (output_end_row, input_end_row) = cursor.end();
|
||||
let output_start = Point::new(output_start_row.0, 0);
|
||||
let input_start = Point::new(input_start_row.0, 0);
|
||||
let input_end = Point::new(input_end_row.0, 0);
|
||||
|
@ -1584,23 +1584,23 @@ impl BlockSnapshot {
|
|||
}
|
||||
|
||||
if search_left {
|
||||
cursor.prev(&());
|
||||
cursor.prev();
|
||||
} else {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
} else if reversed {
|
||||
return self.max_point();
|
||||
} else {
|
||||
reversed = true;
|
||||
search_left = !search_left;
|
||||
cursor.seek(&BlockRow(point.row), Bias::Right, &());
|
||||
cursor.seek(&BlockRow(point.row), Bias::Right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_block_point(&self, wrap_point: WrapPoint) -> BlockPoint {
|
||||
let mut cursor = self.transforms.cursor::<(WrapRow, BlockRow)>(&());
|
||||
cursor.seek(&WrapRow(wrap_point.row()), Bias::Right, &());
|
||||
cursor.seek(&WrapRow(wrap_point.row()), Bias::Right);
|
||||
if let Some(transform) = cursor.item() {
|
||||
if transform.block.is_some() {
|
||||
BlockPoint::new(cursor.start().1.0, 0)
|
||||
|
@ -1618,7 +1618,7 @@ impl BlockSnapshot {
|
|||
|
||||
pub fn to_wrap_point(&self, block_point: BlockPoint, bias: Bias) -> WrapPoint {
|
||||
let mut cursor = self.transforms.cursor::<(BlockRow, WrapRow)>(&());
|
||||
cursor.seek(&BlockRow(block_point.row), Bias::Right, &());
|
||||
cursor.seek(&BlockRow(block_point.row), Bias::Right);
|
||||
if let Some(transform) = cursor.item() {
|
||||
match transform.block.as_ref() {
|
||||
Some(block) => {
|
||||
|
@ -1630,7 +1630,7 @@ impl BlockSnapshot {
|
|||
} else if bias == Bias::Left {
|
||||
WrapPoint::new(cursor.start().1.0, 0)
|
||||
} else {
|
||||
let wrap_row = cursor.end(&()).1.0 - 1;
|
||||
let wrap_row = cursor.end().1.0 - 1;
|
||||
WrapPoint::new(wrap_row, self.wrap_snapshot.line_len(wrap_row))
|
||||
}
|
||||
}
|
||||
|
@ -1650,14 +1650,14 @@ impl BlockChunks<'_> {
|
|||
/// Go to the next transform
|
||||
fn advance(&mut self) {
|
||||
self.input_chunk = Chunk::default();
|
||||
self.transforms.next(&());
|
||||
self.transforms.next();
|
||||
while let Some(transform) = self.transforms.item() {
|
||||
if transform
|
||||
.block
|
||||
.as_ref()
|
||||
.map_or(false, |block| block.height() == 0)
|
||||
{
|
||||
self.transforms.next(&());
|
||||
self.transforms.next();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -1672,7 +1672,7 @@ impl BlockChunks<'_> {
|
|||
let start_output_row = self.transforms.start().0.0;
|
||||
if start_output_row < self.max_output_row {
|
||||
let end_input_row = cmp::min(
|
||||
self.transforms.end(&()).1.0,
|
||||
self.transforms.end().1.0,
|
||||
start_input_row + (self.max_output_row - start_output_row),
|
||||
);
|
||||
self.input_chunks.seek(start_input_row..end_input_row);
|
||||
|
@ -1696,7 +1696,7 @@ impl<'a> Iterator for BlockChunks<'a> {
|
|||
let transform = self.transforms.item()?;
|
||||
if transform.block.is_some() {
|
||||
let block_start = self.transforms.start().0.0;
|
||||
let mut block_end = self.transforms.end(&()).0.0;
|
||||
let mut block_end = self.transforms.end().0.0;
|
||||
self.advance();
|
||||
if self.transforms.item().is_none() {
|
||||
block_end -= 1;
|
||||
|
@ -1731,7 +1731,7 @@ impl<'a> Iterator for BlockChunks<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
let transform_end = self.transforms.end(&()).0.0;
|
||||
let transform_end = self.transforms.end().0.0;
|
||||
let (prefix_rows, prefix_bytes) =
|
||||
offset_for_row(self.input_chunk.text, transform_end - self.output_row);
|
||||
self.output_row += prefix_rows;
|
||||
|
@ -1770,15 +1770,15 @@ impl Iterator for BlockRows<'_> {
|
|||
self.started = true;
|
||||
}
|
||||
|
||||
if self.output_row.0 >= self.transforms.end(&()).0.0 {
|
||||
self.transforms.next(&());
|
||||
if self.output_row.0 >= self.transforms.end().0.0 {
|
||||
self.transforms.next();
|
||||
while let Some(transform) = self.transforms.item() {
|
||||
if transform
|
||||
.block
|
||||
.as_ref()
|
||||
.map_or(false, |block| block.height() == 0)
|
||||
{
|
||||
self.transforms.next(&());
|
||||
self.transforms.next();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -52,15 +52,15 @@ impl CreaseSnapshot {
|
|||
) -> Option<&'a Crease<Anchor>> {
|
||||
let start = snapshot.anchor_before(Point::new(row.0, 0));
|
||||
let mut cursor = self.creases.cursor::<ItemSummary>(snapshot);
|
||||
cursor.seek(&start, Bias::Left, snapshot);
|
||||
cursor.seek(&start, Bias::Left);
|
||||
while let Some(item) = cursor.item() {
|
||||
match Ord::cmp(&item.crease.range().start.to_point(snapshot).row, &row.0) {
|
||||
Ordering::Less => cursor.next(snapshot),
|
||||
Ordering::Less => cursor.next(),
|
||||
Ordering::Equal => {
|
||||
if item.crease.range().start.is_valid(snapshot) {
|
||||
return Some(&item.crease);
|
||||
} else {
|
||||
cursor.next(snapshot);
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
Ordering::Greater => break,
|
||||
|
@ -76,11 +76,11 @@ impl CreaseSnapshot {
|
|||
) -> impl 'a + Iterator<Item = &'a Crease<Anchor>> {
|
||||
let start = snapshot.anchor_before(Point::new(range.start.0, 0));
|
||||
let mut cursor = self.creases.cursor::<ItemSummary>(snapshot);
|
||||
cursor.seek(&start, Bias::Left, snapshot);
|
||||
cursor.seek(&start, Bias::Left);
|
||||
|
||||
std::iter::from_fn(move || {
|
||||
while let Some(item) = cursor.item() {
|
||||
cursor.next(snapshot);
|
||||
cursor.next();
|
||||
let crease_range = item.crease.range();
|
||||
let crease_start = crease_range.start.to_point(snapshot);
|
||||
let crease_end = crease_range.end.to_point(snapshot);
|
||||
|
@ -102,13 +102,13 @@ impl CreaseSnapshot {
|
|||
let mut cursor = self.creases.cursor::<ItemSummary>(snapshot);
|
||||
let mut results = Vec::new();
|
||||
|
||||
cursor.next(snapshot);
|
||||
cursor.next();
|
||||
while let Some(item) = cursor.item() {
|
||||
let crease_range = item.crease.range();
|
||||
let start_point = crease_range.start.to_point(snapshot);
|
||||
let end_point = crease_range.end.to_point(snapshot);
|
||||
results.push((item.id, start_point..end_point));
|
||||
cursor.next(snapshot);
|
||||
cursor.next();
|
||||
}
|
||||
|
||||
results
|
||||
|
@ -298,7 +298,7 @@ impl CreaseMap {
|
|||
let mut cursor = self.snapshot.creases.cursor::<ItemSummary>(snapshot);
|
||||
for crease in creases {
|
||||
let crease_range = crease.range().clone();
|
||||
new_creases.append(cursor.slice(&crease_range, Bias::Left, snapshot), snapshot);
|
||||
new_creases.append(cursor.slice(&crease_range, Bias::Left), snapshot);
|
||||
|
||||
let id = self.next_id;
|
||||
self.next_id.0 += 1;
|
||||
|
@ -306,7 +306,7 @@ impl CreaseMap {
|
|||
new_creases.push(CreaseItem { crease, id }, snapshot);
|
||||
new_ids.push(id);
|
||||
}
|
||||
new_creases.append(cursor.suffix(snapshot), snapshot);
|
||||
new_creases.append(cursor.suffix(), snapshot);
|
||||
new_creases
|
||||
};
|
||||
new_ids
|
||||
|
@ -332,9 +332,9 @@ impl CreaseMap {
|
|||
let mut cursor = self.snapshot.creases.cursor::<ItemSummary>(snapshot);
|
||||
|
||||
for (id, range) in &removals {
|
||||
new_creases.append(cursor.slice(range, Bias::Left, snapshot), snapshot);
|
||||
new_creases.append(cursor.slice(range, Bias::Left), snapshot);
|
||||
while let Some(item) = cursor.item() {
|
||||
cursor.next(snapshot);
|
||||
cursor.next();
|
||||
if item.id == *id {
|
||||
break;
|
||||
} else {
|
||||
|
@ -343,7 +343,7 @@ impl CreaseMap {
|
|||
}
|
||||
}
|
||||
|
||||
new_creases.append(cursor.suffix(snapshot), snapshot);
|
||||
new_creases.append(cursor.suffix(), snapshot);
|
||||
new_creases
|
||||
};
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ impl FoldPoint {
|
|||
|
||||
pub fn to_inlay_point(self, snapshot: &FoldSnapshot) -> InlayPoint {
|
||||
let mut cursor = snapshot.transforms.cursor::<(FoldPoint, InlayPoint)>(&());
|
||||
cursor.seek(&self, Bias::Right, &());
|
||||
cursor.seek(&self, Bias::Right);
|
||||
let overshoot = self.0 - cursor.start().0.0;
|
||||
InlayPoint(cursor.start().1.0 + overshoot)
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ impl FoldPoint {
|
|||
let mut cursor = snapshot
|
||||
.transforms
|
||||
.cursor::<(FoldPoint, TransformSummary)>(&());
|
||||
cursor.seek(&self, Bias::Right, &());
|
||||
cursor.seek(&self, Bias::Right);
|
||||
let overshoot = self.0 - cursor.start().1.output.lines;
|
||||
let mut offset = cursor.start().1.output.len;
|
||||
if !overshoot.is_zero() {
|
||||
|
@ -187,10 +187,10 @@ impl FoldMapWriter<'_> {
|
|||
width: None,
|
||||
},
|
||||
);
|
||||
new_tree.append(cursor.slice(&fold.range, Bias::Right, buffer), buffer);
|
||||
new_tree.append(cursor.slice(&fold.range, Bias::Right), buffer);
|
||||
new_tree.push(fold, buffer);
|
||||
}
|
||||
new_tree.append(cursor.suffix(buffer), buffer);
|
||||
new_tree.append(cursor.suffix(), buffer);
|
||||
new_tree
|
||||
};
|
||||
|
||||
|
@ -252,7 +252,7 @@ impl FoldMapWriter<'_> {
|
|||
fold_ixs_to_delete.push(*folds_cursor.start());
|
||||
self.0.snapshot.fold_metadata_by_id.remove(&fold.id);
|
||||
}
|
||||
folds_cursor.next(buffer);
|
||||
folds_cursor.next();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,10 +263,10 @@ impl FoldMapWriter<'_> {
|
|||
let mut cursor = self.0.snapshot.folds.cursor::<usize>(buffer);
|
||||
let mut folds = SumTree::new(buffer);
|
||||
for fold_ix in fold_ixs_to_delete {
|
||||
folds.append(cursor.slice(&fold_ix, Bias::Right, buffer), buffer);
|
||||
cursor.next(buffer);
|
||||
folds.append(cursor.slice(&fold_ix, Bias::Right), buffer);
|
||||
cursor.next();
|
||||
}
|
||||
folds.append(cursor.suffix(buffer), buffer);
|
||||
folds.append(cursor.suffix(), buffer);
|
||||
folds
|
||||
};
|
||||
|
||||
|
@ -412,7 +412,7 @@ impl FoldMap {
|
|||
|
||||
let mut new_transforms = SumTree::<Transform>::default();
|
||||
let mut cursor = self.snapshot.transforms.cursor::<InlayOffset>(&());
|
||||
cursor.seek(&InlayOffset(0), Bias::Right, &());
|
||||
cursor.seek(&InlayOffset(0), Bias::Right);
|
||||
|
||||
while let Some(mut edit) = inlay_edits_iter.next() {
|
||||
if let Some(item) = cursor.item() {
|
||||
|
@ -421,19 +421,19 @@ impl FoldMap {
|
|||
|transform| {
|
||||
if !transform.is_fold() {
|
||||
transform.summary.add_summary(&item.summary, &());
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
},
|
||||
&(),
|
||||
);
|
||||
}
|
||||
}
|
||||
new_transforms.append(cursor.slice(&edit.old.start, Bias::Left, &()), &());
|
||||
new_transforms.append(cursor.slice(&edit.old.start, Bias::Left), &());
|
||||
edit.new.start -= edit.old.start - *cursor.start();
|
||||
edit.old.start = *cursor.start();
|
||||
|
||||
cursor.seek(&edit.old.end, Bias::Right, &());
|
||||
cursor.next(&());
|
||||
cursor.seek(&edit.old.end, Bias::Right);
|
||||
cursor.next();
|
||||
|
||||
let mut delta = edit.new_len().0 as isize - edit.old_len().0 as isize;
|
||||
loop {
|
||||
|
@ -449,8 +449,8 @@ impl FoldMap {
|
|||
|
||||
if next_edit.old.end >= edit.old.end {
|
||||
edit.old.end = next_edit.old.end;
|
||||
cursor.seek(&edit.old.end, Bias::Right, &());
|
||||
cursor.next(&());
|
||||
cursor.seek(&edit.old.end, Bias::Right);
|
||||
cursor.next();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
|
@ -467,11 +467,7 @@ impl FoldMap {
|
|||
.snapshot
|
||||
.folds
|
||||
.cursor::<FoldRange>(&inlay_snapshot.buffer);
|
||||
folds_cursor.seek(
|
||||
&FoldRange(anchor..Anchor::max()),
|
||||
Bias::Left,
|
||||
&inlay_snapshot.buffer,
|
||||
);
|
||||
folds_cursor.seek(&FoldRange(anchor..Anchor::max()), Bias::Left);
|
||||
|
||||
let mut folds = iter::from_fn({
|
||||
let inlay_snapshot = &inlay_snapshot;
|
||||
|
@ -485,7 +481,7 @@ impl FoldMap {
|
|||
..inlay_snapshot.to_inlay_offset(buffer_end),
|
||||
)
|
||||
});
|
||||
folds_cursor.next(&inlay_snapshot.buffer);
|
||||
folds_cursor.next();
|
||||
item
|
||||
}
|
||||
})
|
||||
|
@ -558,7 +554,7 @@ impl FoldMap {
|
|||
}
|
||||
}
|
||||
|
||||
new_transforms.append(cursor.suffix(&()), &());
|
||||
new_transforms.append(cursor.suffix(), &());
|
||||
if new_transforms.is_empty() {
|
||||
let text_summary = inlay_snapshot.text_summary();
|
||||
push_isomorphic(&mut new_transforms, text_summary);
|
||||
|
@ -575,31 +571,31 @@ impl FoldMap {
|
|||
let mut new_transforms = new_transforms.cursor::<(InlayOffset, FoldOffset)>(&());
|
||||
|
||||
for mut edit in inlay_edits {
|
||||
old_transforms.seek(&edit.old.start, Bias::Left, &());
|
||||
old_transforms.seek(&edit.old.start, Bias::Left);
|
||||
if old_transforms.item().map_or(false, |t| t.is_fold()) {
|
||||
edit.old.start = old_transforms.start().0;
|
||||
}
|
||||
let old_start =
|
||||
old_transforms.start().1.0 + (edit.old.start - old_transforms.start().0).0;
|
||||
|
||||
old_transforms.seek_forward(&edit.old.end, Bias::Right, &());
|
||||
old_transforms.seek_forward(&edit.old.end, Bias::Right);
|
||||
if old_transforms.item().map_or(false, |t| t.is_fold()) {
|
||||
old_transforms.next(&());
|
||||
old_transforms.next();
|
||||
edit.old.end = old_transforms.start().0;
|
||||
}
|
||||
let old_end =
|
||||
old_transforms.start().1.0 + (edit.old.end - old_transforms.start().0).0;
|
||||
|
||||
new_transforms.seek(&edit.new.start, Bias::Left, &());
|
||||
new_transforms.seek(&edit.new.start, Bias::Left);
|
||||
if new_transforms.item().map_or(false, |t| t.is_fold()) {
|
||||
edit.new.start = new_transforms.start().0;
|
||||
}
|
||||
let new_start =
|
||||
new_transforms.start().1.0 + (edit.new.start - new_transforms.start().0).0;
|
||||
|
||||
new_transforms.seek_forward(&edit.new.end, Bias::Right, &());
|
||||
new_transforms.seek_forward(&edit.new.end, Bias::Right);
|
||||
if new_transforms.item().map_or(false, |t| t.is_fold()) {
|
||||
new_transforms.next(&());
|
||||
new_transforms.next();
|
||||
edit.new.end = new_transforms.start().0;
|
||||
}
|
||||
let new_end =
|
||||
|
@ -656,10 +652,10 @@ impl FoldSnapshot {
|
|||
let mut summary = TextSummary::default();
|
||||
|
||||
let mut cursor = self.transforms.cursor::<(FoldPoint, InlayPoint)>(&());
|
||||
cursor.seek(&range.start, Bias::Right, &());
|
||||
cursor.seek(&range.start, Bias::Right);
|
||||
if let Some(transform) = cursor.item() {
|
||||
let start_in_transform = range.start.0 - cursor.start().0.0;
|
||||
let end_in_transform = cmp::min(range.end, cursor.end(&()).0).0 - cursor.start().0.0;
|
||||
let end_in_transform = cmp::min(range.end, cursor.end().0).0 - cursor.start().0.0;
|
||||
if let Some(placeholder) = transform.placeholder.as_ref() {
|
||||
summary = TextSummary::from(
|
||||
&placeholder.text
|
||||
|
@ -678,10 +674,10 @@ impl FoldSnapshot {
|
|||
}
|
||||
}
|
||||
|
||||
if range.end > cursor.end(&()).0 {
|
||||
cursor.next(&());
|
||||
if range.end > cursor.end().0 {
|
||||
cursor.next();
|
||||
summary += &cursor
|
||||
.summary::<_, TransformSummary>(&range.end, Bias::Right, &())
|
||||
.summary::<_, TransformSummary>(&range.end, Bias::Right)
|
||||
.output;
|
||||
if let Some(transform) = cursor.item() {
|
||||
let end_in_transform = range.end.0 - cursor.start().0.0;
|
||||
|
@ -705,19 +701,16 @@ impl FoldSnapshot {
|
|||
|
||||
pub fn to_fold_point(&self, point: InlayPoint, bias: Bias) -> FoldPoint {
|
||||
let mut cursor = self.transforms.cursor::<(InlayPoint, FoldPoint)>(&());
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
cursor.seek(&point, Bias::Right);
|
||||
if cursor.item().map_or(false, |t| t.is_fold()) {
|
||||
if bias == Bias::Left || point == cursor.start().0 {
|
||||
cursor.start().1
|
||||
} else {
|
||||
cursor.end(&()).1
|
||||
cursor.end().1
|
||||
}
|
||||
} else {
|
||||
let overshoot = point.0 - cursor.start().0.0;
|
||||
FoldPoint(cmp::min(
|
||||
cursor.start().1.0 + overshoot,
|
||||
cursor.end(&()).1.0,
|
||||
))
|
||||
FoldPoint(cmp::min(cursor.start().1.0 + overshoot, cursor.end().1.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -742,7 +735,7 @@ impl FoldSnapshot {
|
|||
|
||||
let fold_point = FoldPoint::new(start_row, 0);
|
||||
let mut cursor = self.transforms.cursor::<(FoldPoint, InlayPoint)>(&());
|
||||
cursor.seek(&fold_point, Bias::Left, &());
|
||||
cursor.seek(&fold_point, Bias::Left);
|
||||
|
||||
let overshoot = fold_point.0 - cursor.start().0.0;
|
||||
let inlay_point = InlayPoint(cursor.start().1.0 + overshoot);
|
||||
|
@ -773,7 +766,7 @@ impl FoldSnapshot {
|
|||
let mut folds = intersecting_folds(&self.inlay_snapshot, &self.folds, range, false);
|
||||
iter::from_fn(move || {
|
||||
let item = folds.item();
|
||||
folds.next(&self.inlay_snapshot.buffer);
|
||||
folds.next();
|
||||
item
|
||||
})
|
||||
}
|
||||
|
@ -785,7 +778,7 @@ impl FoldSnapshot {
|
|||
let buffer_offset = offset.to_offset(&self.inlay_snapshot.buffer);
|
||||
let inlay_offset = self.inlay_snapshot.to_inlay_offset(buffer_offset);
|
||||
let mut cursor = self.transforms.cursor::<InlayOffset>(&());
|
||||
cursor.seek(&inlay_offset, Bias::Right, &());
|
||||
cursor.seek(&inlay_offset, Bias::Right);
|
||||
cursor.item().map_or(false, |t| t.placeholder.is_some())
|
||||
}
|
||||
|
||||
|
@ -794,7 +787,7 @@ impl FoldSnapshot {
|
|||
.inlay_snapshot
|
||||
.to_inlay_point(Point::new(buffer_row.0, 0));
|
||||
let mut cursor = self.transforms.cursor::<InlayPoint>(&());
|
||||
cursor.seek(&inlay_point, Bias::Right, &());
|
||||
cursor.seek(&inlay_point, Bias::Right);
|
||||
loop {
|
||||
match cursor.item() {
|
||||
Some(transform) => {
|
||||
|
@ -808,11 +801,11 @@ impl FoldSnapshot {
|
|||
None => return false,
|
||||
}
|
||||
|
||||
if cursor.end(&()).row() == inlay_point.row() {
|
||||
cursor.next(&());
|
||||
if cursor.end().row() == inlay_point.row() {
|
||||
cursor.next();
|
||||
} else {
|
||||
inlay_point.0 += Point::new(1, 0);
|
||||
cursor.seek(&inlay_point, Bias::Right, &());
|
||||
cursor.seek(&inlay_point, Bias::Right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -824,14 +817,14 @@ impl FoldSnapshot {
|
|||
highlights: Highlights<'a>,
|
||||
) -> FoldChunks<'a> {
|
||||
let mut transform_cursor = self.transforms.cursor::<(FoldOffset, InlayOffset)>(&());
|
||||
transform_cursor.seek(&range.start, Bias::Right, &());
|
||||
transform_cursor.seek(&range.start, Bias::Right);
|
||||
|
||||
let inlay_start = {
|
||||
let overshoot = range.start.0 - transform_cursor.start().0.0;
|
||||
transform_cursor.start().1 + InlayOffset(overshoot)
|
||||
};
|
||||
|
||||
let transform_end = transform_cursor.end(&());
|
||||
let transform_end = transform_cursor.end();
|
||||
|
||||
let inlay_end = if transform_cursor
|
||||
.item()
|
||||
|
@ -879,14 +872,14 @@ impl FoldSnapshot {
|
|||
|
||||
pub fn clip_point(&self, point: FoldPoint, bias: Bias) -> FoldPoint {
|
||||
let mut cursor = self.transforms.cursor::<(FoldPoint, InlayPoint)>(&());
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
cursor.seek(&point, Bias::Right);
|
||||
if let Some(transform) = cursor.item() {
|
||||
let transform_start = cursor.start().0.0;
|
||||
if transform.placeholder.is_some() {
|
||||
if point.0 == transform_start || matches!(bias, Bias::Left) {
|
||||
FoldPoint(transform_start)
|
||||
} else {
|
||||
FoldPoint(cursor.end(&()).0.0)
|
||||
FoldPoint(cursor.end().0.0)
|
||||
}
|
||||
} else {
|
||||
let overshoot = InlayPoint(point.0 - transform_start);
|
||||
|
@ -945,7 +938,7 @@ fn intersecting_folds<'a>(
|
|||
start_cmp == Ordering::Less && end_cmp == Ordering::Greater
|
||||
}
|
||||
});
|
||||
cursor.next(buffer);
|
||||
cursor.next();
|
||||
cursor
|
||||
}
|
||||
|
||||
|
@ -1211,7 +1204,7 @@ pub struct FoldRows<'a> {
|
|||
impl FoldRows<'_> {
|
||||
pub(crate) fn seek(&mut self, row: u32) {
|
||||
let fold_point = FoldPoint::new(row, 0);
|
||||
self.cursor.seek(&fold_point, Bias::Left, &());
|
||||
self.cursor.seek(&fold_point, Bias::Left);
|
||||
let overshoot = fold_point.0 - self.cursor.start().0.0;
|
||||
let inlay_point = InlayPoint(self.cursor.start().1.0 + overshoot);
|
||||
self.input_rows.seek(inlay_point.row());
|
||||
|
@ -1224,8 +1217,8 @@ impl Iterator for FoldRows<'_> {
|
|||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let mut traversed_fold = false;
|
||||
while self.fold_point > self.cursor.end(&()).0 {
|
||||
self.cursor.next(&());
|
||||
while self.fold_point > self.cursor.end().0 {
|
||||
self.cursor.next();
|
||||
traversed_fold = true;
|
||||
if self.cursor.item().is_none() {
|
||||
break;
|
||||
|
@ -1330,14 +1323,14 @@ pub struct FoldChunks<'a> {
|
|||
|
||||
impl FoldChunks<'_> {
|
||||
pub(crate) fn seek(&mut self, range: Range<FoldOffset>) {
|
||||
self.transform_cursor.seek(&range.start, Bias::Right, &());
|
||||
self.transform_cursor.seek(&range.start, Bias::Right);
|
||||
|
||||
let inlay_start = {
|
||||
let overshoot = range.start.0 - self.transform_cursor.start().0.0;
|
||||
self.transform_cursor.start().1 + InlayOffset(overshoot)
|
||||
};
|
||||
|
||||
let transform_end = self.transform_cursor.end(&());
|
||||
let transform_end = self.transform_cursor.end();
|
||||
|
||||
let inlay_end = if self
|
||||
.transform_cursor
|
||||
|
@ -1376,10 +1369,10 @@ impl<'a> Iterator for FoldChunks<'a> {
|
|||
self.inlay_chunk.take();
|
||||
self.inlay_offset += InlayOffset(transform.summary.input.len);
|
||||
|
||||
while self.inlay_offset >= self.transform_cursor.end(&()).1
|
||||
while self.inlay_offset >= self.transform_cursor.end().1
|
||||
&& self.transform_cursor.item().is_some()
|
||||
{
|
||||
self.transform_cursor.next(&());
|
||||
self.transform_cursor.next();
|
||||
}
|
||||
|
||||
self.output_offset.0 += placeholder.text.len();
|
||||
|
@ -1396,7 +1389,7 @@ impl<'a> Iterator for FoldChunks<'a> {
|
|||
&& self.inlay_chunks.offset() != self.inlay_offset
|
||||
{
|
||||
let transform_start = self.transform_cursor.start();
|
||||
let transform_end = self.transform_cursor.end(&());
|
||||
let transform_end = self.transform_cursor.end();
|
||||
let inlay_end = if self.max_output_offset < transform_end.0 {
|
||||
let overshoot = self.max_output_offset.0 - transform_start.0.0;
|
||||
transform_start.1 + InlayOffset(overshoot)
|
||||
|
@ -1417,14 +1410,14 @@ impl<'a> Iterator for FoldChunks<'a> {
|
|||
if let Some((buffer_chunk_start, mut inlay_chunk)) = self.inlay_chunk.clone() {
|
||||
let chunk = &mut inlay_chunk.chunk;
|
||||
let buffer_chunk_end = buffer_chunk_start + InlayOffset(chunk.text.len());
|
||||
let transform_end = self.transform_cursor.end(&()).1;
|
||||
let transform_end = self.transform_cursor.end().1;
|
||||
let chunk_end = buffer_chunk_end.min(transform_end);
|
||||
|
||||
chunk.text = &chunk.text
|
||||
[(self.inlay_offset - buffer_chunk_start).0..(chunk_end - buffer_chunk_start).0];
|
||||
|
||||
if chunk_end == transform_end {
|
||||
self.transform_cursor.next(&());
|
||||
self.transform_cursor.next();
|
||||
} else if chunk_end == buffer_chunk_end {
|
||||
self.inlay_chunk.take();
|
||||
}
|
||||
|
@ -1456,7 +1449,7 @@ impl FoldOffset {
|
|||
let mut cursor = snapshot
|
||||
.transforms
|
||||
.cursor::<(FoldOffset, TransformSummary)>(&());
|
||||
cursor.seek(&self, Bias::Right, &());
|
||||
cursor.seek(&self, Bias::Right);
|
||||
let overshoot = if cursor.item().map_or(true, |t| t.is_fold()) {
|
||||
Point::new(0, (self.0 - cursor.start().0.0) as u32)
|
||||
} else {
|
||||
|
@ -1470,7 +1463,7 @@ impl FoldOffset {
|
|||
#[cfg(test)]
|
||||
pub fn to_inlay_offset(self, snapshot: &FoldSnapshot) -> InlayOffset {
|
||||
let mut cursor = snapshot.transforms.cursor::<(FoldOffset, InlayOffset)>(&());
|
||||
cursor.seek(&self, Bias::Right, &());
|
||||
cursor.seek(&self, Bias::Right);
|
||||
let overshoot = self.0 - cursor.start().0.0;
|
||||
InlayOffset(cursor.start().1.0 + overshoot)
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ pub struct InlayChunk<'a> {
|
|||
|
||||
impl InlayChunks<'_> {
|
||||
pub fn seek(&mut self, new_range: Range<InlayOffset>) {
|
||||
self.transforms.seek(&new_range.start, Bias::Right, &());
|
||||
self.transforms.seek(&new_range.start, Bias::Right);
|
||||
|
||||
let buffer_range = self.snapshot.to_buffer_offset(new_range.start)
|
||||
..self.snapshot.to_buffer_offset(new_range.end);
|
||||
|
@ -296,12 +296,12 @@ impl<'a> Iterator for InlayChunks<'a> {
|
|||
*chunk = self.buffer_chunks.next().unwrap();
|
||||
}
|
||||
|
||||
let desired_bytes = self.transforms.end(&()).0.0 - self.output_offset.0;
|
||||
let desired_bytes = self.transforms.end().0.0 - self.output_offset.0;
|
||||
|
||||
// If we're already at the transform boundary, skip to the next transform
|
||||
if desired_bytes == 0 {
|
||||
self.inlay_chunks = None;
|
||||
self.transforms.next(&());
|
||||
self.transforms.next();
|
||||
return self.next();
|
||||
}
|
||||
|
||||
|
@ -397,7 +397,7 @@ impl<'a> Iterator for InlayChunks<'a> {
|
|||
|
||||
let inlay_chunks = self.inlay_chunks.get_or_insert_with(|| {
|
||||
let start = offset_in_inlay;
|
||||
let end = cmp::min(self.max_output_offset, self.transforms.end(&()).0)
|
||||
let end = cmp::min(self.max_output_offset, self.transforms.end().0)
|
||||
- self.transforms.start().0;
|
||||
inlay.text.chunks_in_range(start.0..end.0)
|
||||
});
|
||||
|
@ -441,9 +441,9 @@ impl<'a> Iterator for InlayChunks<'a> {
|
|||
}
|
||||
};
|
||||
|
||||
if self.output_offset >= self.transforms.end(&()).0 {
|
||||
if self.output_offset >= self.transforms.end().0 {
|
||||
self.inlay_chunks = None;
|
||||
self.transforms.next(&());
|
||||
self.transforms.next();
|
||||
}
|
||||
|
||||
Some(chunk)
|
||||
|
@ -453,7 +453,7 @@ impl<'a> Iterator for InlayChunks<'a> {
|
|||
impl InlayBufferRows<'_> {
|
||||
pub fn seek(&mut self, row: u32) {
|
||||
let inlay_point = InlayPoint::new(row, 0);
|
||||
self.transforms.seek(&inlay_point, Bias::Left, &());
|
||||
self.transforms.seek(&inlay_point, Bias::Left);
|
||||
|
||||
let mut buffer_point = self.transforms.start().1;
|
||||
let buffer_row = MultiBufferRow(if row == 0 {
|
||||
|
@ -487,7 +487,7 @@ impl Iterator for InlayBufferRows<'_> {
|
|||
|
||||
self.inlay_row += 1;
|
||||
self.transforms
|
||||
.seek_forward(&InlayPoint::new(self.inlay_row, 0), Bias::Left, &());
|
||||
.seek_forward(&InlayPoint::new(self.inlay_row, 0), Bias::Left);
|
||||
|
||||
Some(buffer_row)
|
||||
}
|
||||
|
@ -556,18 +556,18 @@ impl InlayMap {
|
|||
let mut cursor = snapshot.transforms.cursor::<(usize, InlayOffset)>(&());
|
||||
let mut buffer_edits_iter = buffer_edits.iter().peekable();
|
||||
while let Some(buffer_edit) = buffer_edits_iter.next() {
|
||||
new_transforms.append(cursor.slice(&buffer_edit.old.start, Bias::Left, &()), &());
|
||||
new_transforms.append(cursor.slice(&buffer_edit.old.start, Bias::Left), &());
|
||||
if let Some(Transform::Isomorphic(transform)) = cursor.item() {
|
||||
if cursor.end(&()).0 == buffer_edit.old.start {
|
||||
if cursor.end().0 == buffer_edit.old.start {
|
||||
push_isomorphic(&mut new_transforms, *transform);
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all the inlays and transforms contained by the edit.
|
||||
let old_start =
|
||||
cursor.start().1 + InlayOffset(buffer_edit.old.start - cursor.start().0);
|
||||
cursor.seek(&buffer_edit.old.end, Bias::Right, &());
|
||||
cursor.seek(&buffer_edit.old.end, Bias::Right);
|
||||
let old_end =
|
||||
cursor.start().1 + InlayOffset(buffer_edit.old.end - cursor.start().0);
|
||||
|
||||
|
@ -625,20 +625,20 @@ impl InlayMap {
|
|||
// we can push its remainder.
|
||||
if buffer_edits_iter
|
||||
.peek()
|
||||
.map_or(true, |edit| edit.old.start >= cursor.end(&()).0)
|
||||
.map_or(true, |edit| edit.old.start >= cursor.end().0)
|
||||
{
|
||||
let transform_start = new_transforms.summary().input.len;
|
||||
let transform_end =
|
||||
buffer_edit.new.end + (cursor.end(&()).0 - buffer_edit.old.end);
|
||||
buffer_edit.new.end + (cursor.end().0 - buffer_edit.old.end);
|
||||
push_isomorphic(
|
||||
&mut new_transforms,
|
||||
buffer_snapshot.text_summary_for_range(transform_start..transform_end),
|
||||
);
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
|
||||
new_transforms.append(cursor.suffix(&()), &());
|
||||
new_transforms.append(cursor.suffix(), &());
|
||||
if new_transforms.is_empty() {
|
||||
new_transforms.push(Transform::Isomorphic(Default::default()), &());
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ impl InlaySnapshot {
|
|||
let mut cursor = self
|
||||
.transforms
|
||||
.cursor::<(InlayOffset, (InlayPoint, usize))>(&());
|
||||
cursor.seek(&offset, Bias::Right, &());
|
||||
cursor.seek(&offset, Bias::Right);
|
||||
let overshoot = offset.0 - cursor.start().0.0;
|
||||
match cursor.item() {
|
||||
Some(Transform::Isomorphic(_)) => {
|
||||
|
@ -803,7 +803,7 @@ impl InlaySnapshot {
|
|||
let mut cursor = self
|
||||
.transforms
|
||||
.cursor::<(InlayPoint, (InlayOffset, Point))>(&());
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
cursor.seek(&point, Bias::Right);
|
||||
let overshoot = point.0 - cursor.start().0.0;
|
||||
match cursor.item() {
|
||||
Some(Transform::Isomorphic(_)) => {
|
||||
|
@ -822,7 +822,7 @@ impl InlaySnapshot {
|
|||
}
|
||||
pub fn to_buffer_point(&self, point: InlayPoint) -> Point {
|
||||
let mut cursor = self.transforms.cursor::<(InlayPoint, Point)>(&());
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
cursor.seek(&point, Bias::Right);
|
||||
match cursor.item() {
|
||||
Some(Transform::Isomorphic(_)) => {
|
||||
let overshoot = point.0 - cursor.start().0.0;
|
||||
|
@ -834,7 +834,7 @@ impl InlaySnapshot {
|
|||
}
|
||||
pub fn to_buffer_offset(&self, offset: InlayOffset) -> usize {
|
||||
let mut cursor = self.transforms.cursor::<(InlayOffset, usize)>(&());
|
||||
cursor.seek(&offset, Bias::Right, &());
|
||||
cursor.seek(&offset, Bias::Right);
|
||||
match cursor.item() {
|
||||
Some(Transform::Isomorphic(_)) => {
|
||||
let overshoot = offset - cursor.start().0;
|
||||
|
@ -847,19 +847,19 @@ impl InlaySnapshot {
|
|||
|
||||
pub fn to_inlay_offset(&self, offset: usize) -> InlayOffset {
|
||||
let mut cursor = self.transforms.cursor::<(usize, InlayOffset)>(&());
|
||||
cursor.seek(&offset, Bias::Left, &());
|
||||
cursor.seek(&offset, Bias::Left);
|
||||
loop {
|
||||
match cursor.item() {
|
||||
Some(Transform::Isomorphic(_)) => {
|
||||
if offset == cursor.end(&()).0 {
|
||||
if offset == cursor.end().0 {
|
||||
while let Some(Transform::Inlay(inlay)) = cursor.next_item() {
|
||||
if inlay.position.bias() == Bias::Right {
|
||||
break;
|
||||
} else {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
return cursor.end(&()).1;
|
||||
return cursor.end().1;
|
||||
} else {
|
||||
let overshoot = offset - cursor.start().0;
|
||||
return InlayOffset(cursor.start().1.0 + overshoot);
|
||||
|
@ -867,7 +867,7 @@ impl InlaySnapshot {
|
|||
}
|
||||
Some(Transform::Inlay(inlay)) => {
|
||||
if inlay.position.bias() == Bias::Left {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
} else {
|
||||
return cursor.start().1;
|
||||
}
|
||||
|
@ -880,19 +880,19 @@ impl InlaySnapshot {
|
|||
}
|
||||
pub fn to_inlay_point(&self, point: Point) -> InlayPoint {
|
||||
let mut cursor = self.transforms.cursor::<(Point, InlayPoint)>(&());
|
||||
cursor.seek(&point, Bias::Left, &());
|
||||
cursor.seek(&point, Bias::Left);
|
||||
loop {
|
||||
match cursor.item() {
|
||||
Some(Transform::Isomorphic(_)) => {
|
||||
if point == cursor.end(&()).0 {
|
||||
if point == cursor.end().0 {
|
||||
while let Some(Transform::Inlay(inlay)) = cursor.next_item() {
|
||||
if inlay.position.bias() == Bias::Right {
|
||||
break;
|
||||
} else {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
return cursor.end(&()).1;
|
||||
return cursor.end().1;
|
||||
} else {
|
||||
let overshoot = point - cursor.start().0;
|
||||
return InlayPoint(cursor.start().1.0 + overshoot);
|
||||
|
@ -900,7 +900,7 @@ impl InlaySnapshot {
|
|||
}
|
||||
Some(Transform::Inlay(inlay)) => {
|
||||
if inlay.position.bias() == Bias::Left {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
} else {
|
||||
return cursor.start().1;
|
||||
}
|
||||
|
@ -914,7 +914,7 @@ impl InlaySnapshot {
|
|||
|
||||
pub fn clip_point(&self, mut point: InlayPoint, mut bias: Bias) -> InlayPoint {
|
||||
let mut cursor = self.transforms.cursor::<(InlayPoint, Point)>(&());
|
||||
cursor.seek(&point, Bias::Left, &());
|
||||
cursor.seek(&point, Bias::Left);
|
||||
loop {
|
||||
match cursor.item() {
|
||||
Some(Transform::Isomorphic(transform)) => {
|
||||
|
@ -923,7 +923,7 @@ impl InlaySnapshot {
|
|||
if inlay.position.bias() == Bias::Left {
|
||||
return point;
|
||||
} else if bias == Bias::Left {
|
||||
cursor.prev(&());
|
||||
cursor.prev();
|
||||
} else if transform.first_line_chars == 0 {
|
||||
point.0 += Point::new(1, 0);
|
||||
} else {
|
||||
|
@ -932,12 +932,12 @@ impl InlaySnapshot {
|
|||
} else {
|
||||
return point;
|
||||
}
|
||||
} else if cursor.end(&()).0 == point {
|
||||
} else if cursor.end().0 == point {
|
||||
if let Some(Transform::Inlay(inlay)) = cursor.next_item() {
|
||||
if inlay.position.bias() == Bias::Right {
|
||||
return point;
|
||||
} else if bias == Bias::Right {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
} else if point.0.column == 0 {
|
||||
point.0.row -= 1;
|
||||
point.0.column = self.line_len(point.0.row);
|
||||
|
@ -970,7 +970,7 @@ impl InlaySnapshot {
|
|||
}
|
||||
_ => return point,
|
||||
}
|
||||
} else if point == cursor.end(&()).0 && inlay.position.bias() == Bias::Left {
|
||||
} else if point == cursor.end().0 && inlay.position.bias() == Bias::Left {
|
||||
match cursor.next_item() {
|
||||
Some(Transform::Inlay(inlay)) => {
|
||||
if inlay.position.bias() == Bias::Right {
|
||||
|
@ -983,9 +983,9 @@ impl InlaySnapshot {
|
|||
|
||||
if bias == Bias::Left {
|
||||
point = cursor.start().0;
|
||||
cursor.prev(&());
|
||||
cursor.prev();
|
||||
} else {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
point = cursor.start().0;
|
||||
}
|
||||
}
|
||||
|
@ -993,9 +993,9 @@ impl InlaySnapshot {
|
|||
bias = bias.invert();
|
||||
if bias == Bias::Left {
|
||||
point = cursor.start().0;
|
||||
cursor.prev(&());
|
||||
cursor.prev();
|
||||
} else {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
point = cursor.start().0;
|
||||
}
|
||||
}
|
||||
|
@ -1011,7 +1011,7 @@ impl InlaySnapshot {
|
|||
let mut summary = TextSummary::default();
|
||||
|
||||
let mut cursor = self.transforms.cursor::<(InlayOffset, usize)>(&());
|
||||
cursor.seek(&range.start, Bias::Right, &());
|
||||
cursor.seek(&range.start, Bias::Right);
|
||||
|
||||
let overshoot = range.start.0 - cursor.start().0.0;
|
||||
match cursor.item() {
|
||||
|
@ -1019,22 +1019,22 @@ impl InlaySnapshot {
|
|||
let buffer_start = cursor.start().1;
|
||||
let suffix_start = buffer_start + overshoot;
|
||||
let suffix_end =
|
||||
buffer_start + (cmp::min(cursor.end(&()).0, range.end).0 - cursor.start().0.0);
|
||||
buffer_start + (cmp::min(cursor.end().0, range.end).0 - cursor.start().0.0);
|
||||
summary = self.buffer.text_summary_for_range(suffix_start..suffix_end);
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
Some(Transform::Inlay(inlay)) => {
|
||||
let suffix_start = overshoot;
|
||||
let suffix_end = cmp::min(cursor.end(&()).0, range.end).0 - cursor.start().0.0;
|
||||
let suffix_end = cmp::min(cursor.end().0, range.end).0 - cursor.start().0.0;
|
||||
summary = inlay.text.cursor(suffix_start).summary(suffix_end);
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
if range.end > cursor.start().0 {
|
||||
summary += cursor
|
||||
.summary::<_, TransformSummary>(&range.end, Bias::Right, &())
|
||||
.summary::<_, TransformSummary>(&range.end, Bias::Right)
|
||||
.output;
|
||||
|
||||
let overshoot = range.end.0 - cursor.start().0.0;
|
||||
|
@ -1060,7 +1060,7 @@ impl InlaySnapshot {
|
|||
pub fn row_infos(&self, row: u32) -> InlayBufferRows<'_> {
|
||||
let mut cursor = self.transforms.cursor::<(InlayPoint, Point)>(&());
|
||||
let inlay_point = InlayPoint::new(row, 0);
|
||||
cursor.seek(&inlay_point, Bias::Left, &());
|
||||
cursor.seek(&inlay_point, Bias::Left);
|
||||
|
||||
let max_buffer_row = self.buffer.max_row();
|
||||
let mut buffer_point = cursor.start().1;
|
||||
|
@ -1101,7 +1101,7 @@ impl InlaySnapshot {
|
|||
highlights: Highlights<'a>,
|
||||
) -> InlayChunks<'a> {
|
||||
let mut cursor = self.transforms.cursor::<(InlayOffset, usize)>(&());
|
||||
cursor.seek(&range.start, Bias::Right, &());
|
||||
cursor.seek(&range.start, Bias::Right);
|
||||
|
||||
let buffer_range = self.to_buffer_offset(range.start)..self.to_buffer_offset(range.end);
|
||||
let buffer_chunks = CustomHighlightsChunks::new(
|
||||
|
|
|
@ -72,7 +72,7 @@ pub struct WrapRows<'a> {
|
|||
impl WrapRows<'_> {
|
||||
pub(crate) fn seek(&mut self, start_row: u32) {
|
||||
self.transforms
|
||||
.seek(&WrapPoint::new(start_row, 0), Bias::Left, &());
|
||||
.seek(&WrapPoint::new(start_row, 0), Bias::Left);
|
||||
let mut input_row = self.transforms.start().1.row();
|
||||
if self.transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
||||
input_row += start_row - self.transforms.start().0.row();
|
||||
|
@ -340,7 +340,7 @@ impl WrapSnapshot {
|
|||
|
||||
let mut tab_edits_iter = tab_edits.iter().peekable();
|
||||
new_transforms =
|
||||
old_cursor.slice(&tab_edits_iter.peek().unwrap().old.start, Bias::Right, &());
|
||||
old_cursor.slice(&tab_edits_iter.peek().unwrap().old.start, Bias::Right);
|
||||
|
||||
while let Some(edit) = tab_edits_iter.next() {
|
||||
if edit.new.start > TabPoint::from(new_transforms.summary().input.lines) {
|
||||
|
@ -356,31 +356,29 @@ impl WrapSnapshot {
|
|||
));
|
||||
}
|
||||
|
||||
old_cursor.seek_forward(&edit.old.end, Bias::Right, &());
|
||||
old_cursor.seek_forward(&edit.old.end, Bias::Right);
|
||||
if let Some(next_edit) = tab_edits_iter.peek() {
|
||||
if next_edit.old.start > old_cursor.end(&()) {
|
||||
if old_cursor.end(&()) > edit.old.end {
|
||||
if next_edit.old.start > old_cursor.end() {
|
||||
if old_cursor.end() > edit.old.end {
|
||||
let summary = self
|
||||
.tab_snapshot
|
||||
.text_summary_for_range(edit.old.end..old_cursor.end(&()));
|
||||
.text_summary_for_range(edit.old.end..old_cursor.end());
|
||||
new_transforms.push_or_extend(Transform::isomorphic(summary));
|
||||
}
|
||||
|
||||
old_cursor.next(&());
|
||||
new_transforms.append(
|
||||
old_cursor.slice(&next_edit.old.start, Bias::Right, &()),
|
||||
&(),
|
||||
);
|
||||
old_cursor.next();
|
||||
new_transforms
|
||||
.append(old_cursor.slice(&next_edit.old.start, Bias::Right), &());
|
||||
}
|
||||
} else {
|
||||
if old_cursor.end(&()) > edit.old.end {
|
||||
if old_cursor.end() > edit.old.end {
|
||||
let summary = self
|
||||
.tab_snapshot
|
||||
.text_summary_for_range(edit.old.end..old_cursor.end(&()));
|
||||
.text_summary_for_range(edit.old.end..old_cursor.end());
|
||||
new_transforms.push_or_extend(Transform::isomorphic(summary));
|
||||
}
|
||||
old_cursor.next(&());
|
||||
new_transforms.append(old_cursor.suffix(&()), &());
|
||||
old_cursor.next();
|
||||
new_transforms.append(old_cursor.suffix(), &());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -441,7 +439,6 @@ impl WrapSnapshot {
|
|||
new_transforms = old_cursor.slice(
|
||||
&TabPoint::new(row_edits.peek().unwrap().old_rows.start, 0),
|
||||
Bias::Right,
|
||||
&(),
|
||||
);
|
||||
|
||||
while let Some(edit) = row_edits.next() {
|
||||
|
@ -516,34 +513,31 @@ impl WrapSnapshot {
|
|||
}
|
||||
new_transforms.extend(edit_transforms, &());
|
||||
|
||||
old_cursor.seek_forward(&TabPoint::new(edit.old_rows.end, 0), Bias::Right, &());
|
||||
old_cursor.seek_forward(&TabPoint::new(edit.old_rows.end, 0), Bias::Right);
|
||||
if let Some(next_edit) = row_edits.peek() {
|
||||
if next_edit.old_rows.start > old_cursor.end(&()).row() {
|
||||
if old_cursor.end(&()) > TabPoint::new(edit.old_rows.end, 0) {
|
||||
if next_edit.old_rows.start > old_cursor.end().row() {
|
||||
if old_cursor.end() > TabPoint::new(edit.old_rows.end, 0) {
|
||||
let summary = self.tab_snapshot.text_summary_for_range(
|
||||
TabPoint::new(edit.old_rows.end, 0)..old_cursor.end(&()),
|
||||
TabPoint::new(edit.old_rows.end, 0)..old_cursor.end(),
|
||||
);
|
||||
new_transforms.push_or_extend(Transform::isomorphic(summary));
|
||||
}
|
||||
old_cursor.next(&());
|
||||
old_cursor.next();
|
||||
new_transforms.append(
|
||||
old_cursor.slice(
|
||||
&TabPoint::new(next_edit.old_rows.start, 0),
|
||||
Bias::Right,
|
||||
&(),
|
||||
),
|
||||
old_cursor
|
||||
.slice(&TabPoint::new(next_edit.old_rows.start, 0), Bias::Right),
|
||||
&(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if old_cursor.end(&()) > TabPoint::new(edit.old_rows.end, 0) {
|
||||
if old_cursor.end() > TabPoint::new(edit.old_rows.end, 0) {
|
||||
let summary = self.tab_snapshot.text_summary_for_range(
|
||||
TabPoint::new(edit.old_rows.end, 0)..old_cursor.end(&()),
|
||||
TabPoint::new(edit.old_rows.end, 0)..old_cursor.end(),
|
||||
);
|
||||
new_transforms.push_or_extend(Transform::isomorphic(summary));
|
||||
}
|
||||
old_cursor.next(&());
|
||||
new_transforms.append(old_cursor.suffix(&()), &());
|
||||
old_cursor.next();
|
||||
new_transforms.append(old_cursor.suffix(), &());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -570,19 +564,19 @@ impl WrapSnapshot {
|
|||
tab_edit.new.start.0.column = 0;
|
||||
tab_edit.new.end.0 += Point::new(1, 0);
|
||||
|
||||
old_cursor.seek(&tab_edit.old.start, Bias::Right, &());
|
||||
old_cursor.seek(&tab_edit.old.start, Bias::Right);
|
||||
let mut old_start = old_cursor.start().output.lines;
|
||||
old_start += tab_edit.old.start.0 - old_cursor.start().input.lines;
|
||||
|
||||
old_cursor.seek(&tab_edit.old.end, Bias::Right, &());
|
||||
old_cursor.seek(&tab_edit.old.end, Bias::Right);
|
||||
let mut old_end = old_cursor.start().output.lines;
|
||||
old_end += tab_edit.old.end.0 - old_cursor.start().input.lines;
|
||||
|
||||
new_cursor.seek(&tab_edit.new.start, Bias::Right, &());
|
||||
new_cursor.seek(&tab_edit.new.start, Bias::Right);
|
||||
let mut new_start = new_cursor.start().output.lines;
|
||||
new_start += tab_edit.new.start.0 - new_cursor.start().input.lines;
|
||||
|
||||
new_cursor.seek(&tab_edit.new.end, Bias::Right, &());
|
||||
new_cursor.seek(&tab_edit.new.end, Bias::Right);
|
||||
let mut new_end = new_cursor.start().output.lines;
|
||||
new_end += tab_edit.new.end.0 - new_cursor.start().input.lines;
|
||||
|
||||
|
@ -605,7 +599,7 @@ impl WrapSnapshot {
|
|||
let output_start = WrapPoint::new(rows.start, 0);
|
||||
let output_end = WrapPoint::new(rows.end, 0);
|
||||
let mut transforms = self.transforms.cursor::<(WrapPoint, TabPoint)>(&());
|
||||
transforms.seek(&output_start, Bias::Right, &());
|
||||
transforms.seek(&output_start, Bias::Right);
|
||||
let mut input_start = TabPoint(transforms.start().1.0);
|
||||
if transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
||||
input_start.0 += output_start.0 - transforms.start().0.0;
|
||||
|
@ -633,7 +627,7 @@ impl WrapSnapshot {
|
|||
|
||||
pub fn line_len(&self, row: u32) -> u32 {
|
||||
let mut cursor = self.transforms.cursor::<(WrapPoint, TabPoint)>(&());
|
||||
cursor.seek(&WrapPoint::new(row + 1, 0), Bias::Left, &());
|
||||
cursor.seek(&WrapPoint::new(row + 1, 0), Bias::Left);
|
||||
if cursor
|
||||
.item()
|
||||
.map_or(false, |transform| transform.is_isomorphic())
|
||||
|
@ -658,10 +652,10 @@ impl WrapSnapshot {
|
|||
let end = WrapPoint::new(rows.end, 0);
|
||||
|
||||
let mut cursor = self.transforms.cursor::<(WrapPoint, TabPoint)>(&());
|
||||
cursor.seek(&start, Bias::Right, &());
|
||||
cursor.seek(&start, Bias::Right);
|
||||
if let Some(transform) = cursor.item() {
|
||||
let start_in_transform = start.0 - cursor.start().0.0;
|
||||
let end_in_transform = cmp::min(end, cursor.end(&()).0).0 - cursor.start().0.0;
|
||||
let end_in_transform = cmp::min(end, cursor.end().0).0 - cursor.start().0.0;
|
||||
if transform.is_isomorphic() {
|
||||
let tab_start = TabPoint(cursor.start().1.0 + start_in_transform);
|
||||
let tab_end = TabPoint(cursor.start().1.0 + end_in_transform);
|
||||
|
@ -678,12 +672,12 @@ impl WrapSnapshot {
|
|||
};
|
||||
}
|
||||
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
|
||||
if rows.end > cursor.start().0.row() {
|
||||
summary += &cursor
|
||||
.summary::<_, TransformSummary>(&WrapPoint::new(rows.end, 0), Bias::Right, &())
|
||||
.summary::<_, TransformSummary>(&WrapPoint::new(rows.end, 0), Bias::Right)
|
||||
.output;
|
||||
|
||||
if let Some(transform) = cursor.item() {
|
||||
|
@ -712,7 +706,7 @@ impl WrapSnapshot {
|
|||
|
||||
pub fn soft_wrap_indent(&self, row: u32) -> Option<u32> {
|
||||
let mut cursor = self.transforms.cursor::<WrapPoint>(&());
|
||||
cursor.seek(&WrapPoint::new(row + 1, 0), Bias::Right, &());
|
||||
cursor.seek(&WrapPoint::new(row + 1, 0), Bias::Right);
|
||||
cursor.item().and_then(|transform| {
|
||||
if transform.is_isomorphic() {
|
||||
None
|
||||
|
@ -728,7 +722,7 @@ impl WrapSnapshot {
|
|||
|
||||
pub fn row_infos(&self, start_row: u32) -> WrapRows<'_> {
|
||||
let mut transforms = self.transforms.cursor::<(WrapPoint, TabPoint)>(&());
|
||||
transforms.seek(&WrapPoint::new(start_row, 0), Bias::Left, &());
|
||||
transforms.seek(&WrapPoint::new(start_row, 0), Bias::Left);
|
||||
let mut input_row = transforms.start().1.row();
|
||||
if transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
||||
input_row += start_row - transforms.start().0.row();
|
||||
|
@ -748,7 +742,7 @@ impl WrapSnapshot {
|
|||
|
||||
pub fn to_tab_point(&self, point: WrapPoint) -> TabPoint {
|
||||
let mut cursor = self.transforms.cursor::<(WrapPoint, TabPoint)>(&());
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
cursor.seek(&point, Bias::Right);
|
||||
let mut tab_point = cursor.start().1.0;
|
||||
if cursor.item().map_or(false, |t| t.is_isomorphic()) {
|
||||
tab_point += point.0 - cursor.start().0.0;
|
||||
|
@ -766,14 +760,14 @@ impl WrapSnapshot {
|
|||
|
||||
pub fn tab_point_to_wrap_point(&self, point: TabPoint) -> WrapPoint {
|
||||
let mut cursor = self.transforms.cursor::<(TabPoint, WrapPoint)>(&());
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
cursor.seek(&point, Bias::Right);
|
||||
WrapPoint(cursor.start().1.0 + (point.0 - cursor.start().0.0))
|
||||
}
|
||||
|
||||
pub fn clip_point(&self, mut point: WrapPoint, bias: Bias) -> WrapPoint {
|
||||
if bias == Bias::Left {
|
||||
let mut cursor = self.transforms.cursor::<WrapPoint>(&());
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
cursor.seek(&point, Bias::Right);
|
||||
if cursor.item().map_or(false, |t| !t.is_isomorphic()) {
|
||||
point = *cursor.start();
|
||||
*point.column_mut() -= 1;
|
||||
|
@ -791,16 +785,16 @@ impl WrapSnapshot {
|
|||
*point.column_mut() = 0;
|
||||
|
||||
let mut cursor = self.transforms.cursor::<(WrapPoint, TabPoint)>(&());
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
cursor.seek(&point, Bias::Right);
|
||||
if cursor.item().is_none() {
|
||||
cursor.prev(&());
|
||||
cursor.prev();
|
||||
}
|
||||
|
||||
while let Some(transform) = cursor.item() {
|
||||
if transform.is_isomorphic() && cursor.start().1.column() == 0 {
|
||||
return cmp::min(cursor.end(&()).0.row(), point.row());
|
||||
return cmp::min(cursor.end().0.row(), point.row());
|
||||
} else {
|
||||
cursor.prev(&());
|
||||
cursor.prev();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -811,12 +805,12 @@ impl WrapSnapshot {
|
|||
point.0 += Point::new(1, 0);
|
||||
|
||||
let mut cursor = self.transforms.cursor::<(WrapPoint, TabPoint)>(&());
|
||||
cursor.seek(&point, Bias::Right, &());
|
||||
cursor.seek(&point, Bias::Right);
|
||||
while let Some(transform) = cursor.item() {
|
||||
if transform.is_isomorphic() && cursor.start().1.column() == 0 {
|
||||
return Some(cmp::max(cursor.start().0.row(), point.row()));
|
||||
} else {
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -889,7 +883,7 @@ impl WrapChunks<'_> {
|
|||
pub(crate) fn seek(&mut self, rows: Range<u32>) {
|
||||
let output_start = WrapPoint::new(rows.start, 0);
|
||||
let output_end = WrapPoint::new(rows.end, 0);
|
||||
self.transforms.seek(&output_start, Bias::Right, &());
|
||||
self.transforms.seek(&output_start, Bias::Right);
|
||||
let mut input_start = TabPoint(self.transforms.start().1.0);
|
||||
if self.transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
||||
input_start.0 += output_start.0 - self.transforms.start().0.0;
|
||||
|
@ -930,7 +924,7 @@ impl<'a> Iterator for WrapChunks<'a> {
|
|||
}
|
||||
|
||||
self.output_position.0 += summary;
|
||||
self.transforms.next(&());
|
||||
self.transforms.next();
|
||||
return Some(Chunk {
|
||||
text: &display_text[start_ix..end_ix],
|
||||
..Default::default()
|
||||
|
@ -942,7 +936,7 @@ impl<'a> Iterator for WrapChunks<'a> {
|
|||
}
|
||||
|
||||
let mut input_len = 0;
|
||||
let transform_end = self.transforms.end(&()).0;
|
||||
let transform_end = self.transforms.end().0;
|
||||
for c in self.input_chunk.text.chars() {
|
||||
let char_len = c.len_utf8();
|
||||
input_len += char_len;
|
||||
|
@ -954,7 +948,7 @@ impl<'a> Iterator for WrapChunks<'a> {
|
|||
}
|
||||
|
||||
if self.output_position >= transform_end {
|
||||
self.transforms.next(&());
|
||||
self.transforms.next();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -982,7 +976,7 @@ impl Iterator for WrapRows<'_> {
|
|||
|
||||
self.output_row += 1;
|
||||
self.transforms
|
||||
.seek_forward(&WrapPoint::new(self.output_row, 0), Bias::Left, &());
|
||||
.seek_forward(&WrapPoint::new(self.output_row, 0), Bias::Left);
|
||||
if self.transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
||||
self.input_buffer_row = self.input_buffer_rows.next().unwrap();
|
||||
self.soft_wrapped = false;
|
||||
|
|
|
@ -296,7 +296,7 @@ impl GitBlame {
|
|||
let row = info
|
||||
.buffer_row
|
||||
.filter(|_| info.buffer_id == Some(buffer_id))?;
|
||||
cursor.seek_forward(&row, Bias::Right, &());
|
||||
cursor.seek_forward(&row, Bias::Right);
|
||||
cursor.item()?.blame.clone()
|
||||
})
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ impl GitBlame {
|
|||
}
|
||||
}
|
||||
|
||||
new_entries.append(cursor.slice(&edit.old.start, Bias::Right, &()), &());
|
||||
new_entries.append(cursor.slice(&edit.old.start, Bias::Right), &());
|
||||
|
||||
if edit.new.start > new_entries.summary().rows {
|
||||
new_entries.push(
|
||||
|
@ -401,7 +401,7 @@ impl GitBlame {
|
|||
);
|
||||
}
|
||||
|
||||
cursor.seek(&edit.old.end, Bias::Right, &());
|
||||
cursor.seek(&edit.old.end, Bias::Right);
|
||||
if !edit.new.is_empty() {
|
||||
new_entries.push(
|
||||
GitBlameEntry {
|
||||
|
@ -412,7 +412,7 @@ impl GitBlame {
|
|||
);
|
||||
}
|
||||
|
||||
let old_end = cursor.end(&());
|
||||
let old_end = cursor.end();
|
||||
if row_edits
|
||||
.peek()
|
||||
.map_or(true, |next_edit| next_edit.old.start >= old_end)
|
||||
|
@ -421,18 +421,18 @@ impl GitBlame {
|
|||
if old_end > edit.old.end {
|
||||
new_entries.push(
|
||||
GitBlameEntry {
|
||||
rows: cursor.end(&()) - edit.old.end,
|
||||
rows: cursor.end() - edit.old.end,
|
||||
blame: entry.blame.clone(),
|
||||
},
|
||||
&(),
|
||||
);
|
||||
}
|
||||
|
||||
cursor.next(&());
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
new_entries.append(cursor.suffix(&()), &());
|
||||
new_entries.append(cursor.suffix(), &());
|
||||
drop(cursor);
|
||||
|
||||
self.buffer_snapshot = new_snapshot;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue