Add Cursor::seek_end and audit the codebase to use seek_start more

This commit is contained in:
Antonio Scandurra 2021-06-10 13:55:15 +02:00
parent f294bfdbd9
commit dc2805bb14
4 changed files with 82 additions and 76 deletions

View file

@ -128,10 +128,10 @@ impl Rope {
pub fn to_point(&self, offset: usize) -> Point { pub fn to_point(&self, offset: usize) -> Point {
assert!(offset <= self.summary().bytes); assert!(offset <= self.summary().bytes);
let mut cursor = self.chunks.cursor::<usize, TextSummary>(); let mut cursor = self.chunks.cursor::<usize, Point>();
cursor.seek(&offset, Bias::Left, &()); cursor.seek(&offset, Bias::Left, &());
let overshoot = offset - cursor.start().bytes; let overshoot = offset - cursor.seek_start();
cursor.start().lines *cursor.start()
+ cursor + cursor
.item() .item()
.map_or(Point::zero(), |chunk| chunk.to_point(overshoot)) .map_or(Point::zero(), |chunk| chunk.to_point(overshoot))
@ -139,17 +139,17 @@ impl Rope {
pub fn to_offset(&self, point: Point) -> usize { pub fn to_offset(&self, point: Point) -> usize {
assert!(point <= self.summary().lines); assert!(point <= self.summary().lines);
let mut cursor = self.chunks.cursor::<Point, TextSummary>(); let mut cursor = self.chunks.cursor::<Point, usize>();
cursor.seek(&point, Bias::Left, &()); cursor.seek(&point, Bias::Left, &());
let overshoot = point - cursor.start().lines; let overshoot = point - cursor.seek_start();
cursor.start().bytes + cursor.item().map_or(0, |chunk| chunk.to_offset(overshoot)) cursor.start() + cursor.item().map_or(0, |chunk| chunk.to_offset(overshoot))
} }
pub fn clip_offset(&self, mut offset: usize, bias: Bias) -> usize { pub fn clip_offset(&self, mut offset: usize, bias: Bias) -> usize {
let mut cursor = self.chunks.cursor::<usize, usize>(); let mut cursor = self.chunks.cursor::<usize, ()>();
cursor.seek(&offset, Bias::Left, &()); cursor.seek(&offset, Bias::Left, &());
if let Some(chunk) = cursor.item() { if let Some(chunk) = cursor.item() {
let mut ix = offset - cursor.start(); let mut ix = offset - cursor.seek_start();
while !chunk.0.is_char_boundary(ix) { while !chunk.0.is_char_boundary(ix) {
match bias { match bias {
Bias::Left => { Bias::Left => {
@ -169,11 +169,11 @@ impl Rope {
} }
pub fn clip_point(&self, point: Point, bias: Bias) -> Point { pub fn clip_point(&self, point: Point, bias: Bias) -> Point {
let mut cursor = self.chunks.cursor::<Point, Point>(); let mut cursor = self.chunks.cursor::<Point, ()>();
cursor.seek(&point, Bias::Right, &()); cursor.seek(&point, Bias::Right, &());
if let Some(chunk) = cursor.item() { if let Some(chunk) = cursor.item() {
let overshoot = point - cursor.start(); let overshoot = point - cursor.seek_start();
*cursor.start() + chunk.clip_point(overshoot, bias) *cursor.seek_start() + chunk.clip_point(overshoot, bias)
} else { } else {
self.summary().lines self.summary().lines
} }
@ -190,7 +190,7 @@ impl<'a> From<&'a str> for Rope {
pub struct Cursor<'a> { pub struct Cursor<'a> {
rope: &'a Rope, rope: &'a Rope,
chunks: sum_tree::Cursor<'a, Chunk, usize, usize>, chunks: sum_tree::Cursor<'a, Chunk, usize, ()>,
offset: usize, offset: usize,
} }
@ -222,18 +222,18 @@ impl<'a> Cursor<'a> {
let mut slice = Rope::new(); let mut slice = Rope::new();
if let Some(start_chunk) = self.chunks.item() { if let Some(start_chunk) = self.chunks.item() {
let start_ix = self.offset - self.chunks.start(); let start_ix = self.offset - self.chunks.seek_start();
let end_ix = cmp::min(end_offset, self.chunks.end(&())) - self.chunks.start(); let end_ix = cmp::min(end_offset, self.chunks.seek_end(&())) - self.chunks.seek_start();
slice.push(&start_chunk.0[start_ix..end_ix]); slice.push(&start_chunk.0[start_ix..end_ix]);
} }
if end_offset > self.chunks.end(&()) { if end_offset > self.chunks.seek_end(&()) {
self.chunks.next(&()); self.chunks.next(&());
slice.append(Rope { slice.append(Rope {
chunks: self.chunks.slice(&end_offset, Bias::Right, &()), chunks: self.chunks.slice(&end_offset, Bias::Right, &()),
}); });
if let Some(end_chunk) = self.chunks.item() { if let Some(end_chunk) = self.chunks.item() {
let end_ix = end_offset - self.chunks.start(); let end_ix = end_offset - self.chunks.seek_start();
slice.push(&end_chunk.0[..end_ix]); slice.push(&end_chunk.0[..end_ix]);
} }
} }
@ -247,16 +247,16 @@ impl<'a> Cursor<'a> {
let mut summary = TextSummary::default(); let mut summary = TextSummary::default();
if let Some(start_chunk) = self.chunks.item() { if let Some(start_chunk) = self.chunks.item() {
let start_ix = self.offset - self.chunks.start(); let start_ix = self.offset - self.chunks.seek_start();
let end_ix = cmp::min(end_offset, self.chunks.end(&())) - self.chunks.start(); let end_ix = cmp::min(end_offset, self.chunks.seek_end(&())) - self.chunks.seek_start();
summary = TextSummary::from(&start_chunk.0[start_ix..end_ix]); summary = TextSummary::from(&start_chunk.0[start_ix..end_ix]);
} }
if end_offset > self.chunks.end(&()) { if end_offset > self.chunks.seek_end(&()) {
self.chunks.next(&()); self.chunks.next(&());
summary += &self.chunks.summary(&end_offset, Bias::Right, &()); summary += &self.chunks.summary(&end_offset, Bias::Right, &());
if let Some(end_chunk) = self.chunks.item() { if let Some(end_chunk) = self.chunks.item() {
let end_ix = end_offset - self.chunks.start(); let end_ix = end_offset - self.chunks.seek_start();
summary += TextSummary::from(&end_chunk.0[..end_ix]); summary += TextSummary::from(&end_chunk.0[..end_ix]);
} }
} }
@ -274,7 +274,7 @@ impl<'a> Cursor<'a> {
} }
pub struct Chunks<'a> { pub struct Chunks<'a> {
chunks: sum_tree::Cursor<'a, Chunk, usize, usize>, chunks: sum_tree::Cursor<'a, Chunk, usize, ()>,
range: Range<usize>, range: Range<usize>,
} }
@ -286,11 +286,11 @@ impl<'a> Chunks<'a> {
} }
pub fn offset(&self) -> usize { pub fn offset(&self) -> usize {
self.range.start.max(*self.chunks.start()) self.range.start.max(*self.chunks.seek_start())
} }
pub fn seek(&mut self, offset: usize) { pub fn seek(&mut self, offset: usize) {
if offset >= self.chunks.end(&()) { if offset >= self.chunks.seek_end(&()) {
self.chunks.seek_forward(&offset, Bias::Right, &()); self.chunks.seek_forward(&offset, Bias::Right, &());
} else { } else {
self.chunks.seek(&offset, Bias::Right, &()); self.chunks.seek(&offset, Bias::Right, &());
@ -300,10 +300,10 @@ impl<'a> Chunks<'a> {
pub fn peek(&self) -> Option<&'a str> { pub fn peek(&self) -> Option<&'a str> {
if let Some(chunk) = self.chunks.item() { if let Some(chunk) = self.chunks.item() {
let offset = *self.chunks.start(); let offset = *self.chunks.seek_start();
if self.range.end > offset { if self.range.end > offset {
let start = self.range.start.saturating_sub(*self.chunks.start()); let start = self.range.start.saturating_sub(*self.chunks.seek_start());
let end = self.range.end - self.chunks.start(); let end = self.range.end - self.chunks.seek_start();
return Some(&chunk.0[start..chunk.0.len().min(end)]); return Some(&chunk.0[start..chunk.0.len().min(end)]);
} }
} }

View file

@ -210,20 +210,20 @@ impl FoldMap {
let buffer = self.buffer.read(cx); let buffer = self.buffer.read(cx);
let offset = offset.to_offset(buffer); let offset = offset.to_offset(buffer);
let transforms = self.sync(cx); let transforms = self.sync(cx);
let mut cursor = transforms.cursor::<usize, usize>(); let mut cursor = transforms.cursor::<usize, ()>();
cursor.seek(&offset, Bias::Right, &()); cursor.seek(&offset, Bias::Right, &());
cursor.item().map_or(false, |t| t.display_text.is_some()) cursor.item().map_or(false, |t| t.display_text.is_some())
} }
pub fn is_line_folded(&self, display_row: u32, cx: &AppContext) -> bool { pub fn is_line_folded(&self, display_row: u32, cx: &AppContext) -> bool {
let transforms = self.sync(cx); let transforms = self.sync(cx);
let mut cursor = transforms.cursor::<DisplayPoint, DisplayPoint>(); let mut cursor = transforms.cursor::<DisplayPoint, ()>();
cursor.seek(&DisplayPoint::new(display_row, 0), Bias::Right, &()); cursor.seek(&DisplayPoint::new(display_row, 0), Bias::Right, &());
while let Some(transform) = cursor.item() { while let Some(transform) = cursor.item() {
if transform.display_text.is_some() { if transform.display_text.is_some() {
return true; return true;
} }
if cursor.end(&()).row() == display_row { if cursor.seek_end(&()).row() == display_row {
cursor.next(&()) cursor.next(&())
} else { } else {
break; break;
@ -242,21 +242,18 @@ impl FoldMap {
pub fn to_buffer_point(&self, display_point: DisplayPoint, cx: &AppContext) -> Point { pub fn to_buffer_point(&self, display_point: DisplayPoint, cx: &AppContext) -> Point {
let transforms = self.sync(cx); let transforms = self.sync(cx);
let mut cursor = transforms.cursor::<DisplayPoint, TransformSummary>(); let mut cursor = transforms.cursor::<DisplayPoint, Point>();
cursor.seek(&display_point, Bias::Right, &()); cursor.seek(&display_point, Bias::Right, &());
let overshoot = display_point.0 - cursor.start().display.lines; let overshoot = display_point.0 - cursor.seek_start().0;
cursor.start().buffer.lines + overshoot *cursor.start() + overshoot
} }
pub fn to_display_point(&self, point: Point, cx: &AppContext) -> DisplayPoint { pub fn to_display_point(&self, point: Point, cx: &AppContext) -> DisplayPoint {
let transforms = self.sync(cx); let transforms = self.sync(cx);
let mut cursor = transforms.cursor::<Point, TransformSummary>(); let mut cursor = transforms.cursor::<Point, DisplayPoint>();
cursor.seek(&point, Bias::Right, &()); cursor.seek(&point, Bias::Right, &());
let overshoot = point - cursor.start().buffer.lines; let overshoot = point - cursor.seek_start();
DisplayPoint(cmp::min( DisplayPoint(cmp::min(cursor.start().0 + overshoot, cursor.end(&()).0))
cursor.start().display.lines + overshoot,
cursor.end(&()).display.lines,
))
} }
fn sync(&self, cx: &AppContext) -> MutexGuard<SumTree<Transform>> { fn sync(&self, cx: &AppContext) -> MutexGuard<SumTree<Transform>> {
@ -275,20 +272,20 @@ impl FoldMap {
let mut new_transforms = SumTree::new(); let mut new_transforms = SumTree::new();
let mut transforms = self.transforms.lock(); let mut transforms = self.transforms.lock();
let mut cursor = transforms.cursor::<usize, usize>(); let mut cursor = transforms.cursor::<usize, ()>();
cursor.seek(&0, Bias::Right, &()); cursor.seek(&0, Bias::Right, &());
while let Some(mut edit) = edits.next() { while let Some(mut edit) = edits.next() {
new_transforms.push_tree(cursor.slice(&edit.old_range.start, Bias::Left, &()), &()); new_transforms.push_tree(cursor.slice(&edit.old_range.start, Bias::Left, &()), &());
edit.new_range.start -= edit.old_range.start - cursor.start(); edit.new_range.start -= edit.old_range.start - cursor.seek_start();
edit.old_range.start = *cursor.start(); edit.old_range.start = *cursor.seek_start();
cursor.seek(&edit.old_range.end, Bias::Right, &()); cursor.seek(&edit.old_range.end, Bias::Right, &());
cursor.next(&()); cursor.next(&());
let mut delta = edit.delta(); let mut delta = edit.delta();
loop { loop {
edit.old_range.end = *cursor.start(); edit.old_range.end = *cursor.seek_start();
if let Some(next_edit) = edits.peek() { if let Some(next_edit) = edits.peek() {
if next_edit.old_range.start > edit.old_range.end { if next_edit.old_range.start > edit.old_range.end {
@ -443,10 +440,10 @@ impl FoldMapSnapshot {
} }
pub fn chunks_at(&self, offset: DisplayOffset) -> Chunks { pub fn chunks_at(&self, offset: DisplayOffset) -> Chunks {
let mut transform_cursor = self.transforms.cursor::<DisplayOffset, TransformSummary>(); let mut transform_cursor = self.transforms.cursor::<DisplayOffset, usize>();
transform_cursor.seek(&offset, Bias::Right, &()); transform_cursor.seek(&offset, Bias::Right, &());
let overshoot = offset.0 - transform_cursor.start().display.bytes; let overshoot = offset.0 - transform_cursor.seek_start().0;
let buffer_offset = transform_cursor.start().buffer.bytes + overshoot; let buffer_offset = transform_cursor.start() + overshoot;
Chunks { Chunks {
transform_cursor, transform_cursor,
buffer_offset, buffer_offset,
@ -455,15 +452,15 @@ impl FoldMapSnapshot {
} }
pub fn highlighted_chunks(&mut self, range: Range<DisplayOffset>) -> HighlightedChunks { pub fn highlighted_chunks(&mut self, range: Range<DisplayOffset>) -> HighlightedChunks {
let mut transform_cursor = self.transforms.cursor::<DisplayOffset, TransformSummary>(); let mut transform_cursor = self.transforms.cursor::<DisplayOffset, usize>();
transform_cursor.seek(&range.end, Bias::Right, &()); transform_cursor.seek(&range.end, Bias::Right, &());
let overshoot = range.end.0 - transform_cursor.start().display.bytes; let overshoot = range.end.0 - transform_cursor.seek_start().0;
let buffer_end = transform_cursor.start().buffer.bytes + overshoot; let buffer_end = transform_cursor.start() + overshoot;
transform_cursor.seek(&range.start, Bias::Right, &()); transform_cursor.seek(&range.start, Bias::Right, &());
let overshoot = range.start.0 - transform_cursor.start().display.bytes; let overshoot = range.start.0 - transform_cursor.seek_start().0;
let buffer_start = transform_cursor.start().buffer.bytes + overshoot; let buffer_start = transform_cursor.start() + overshoot;
HighlightedChunks { HighlightedChunks {
transform_cursor, transform_cursor,
@ -497,28 +494,27 @@ impl FoldMapSnapshot {
} }
pub fn to_buffer_offset(&self, point: DisplayPoint) -> usize { pub fn to_buffer_offset(&self, point: DisplayPoint) -> usize {
let mut cursor = self.transforms.cursor::<DisplayPoint, TransformSummary>(); let mut cursor = self.transforms.cursor::<DisplayPoint, Point>();
cursor.seek(&point, Bias::Right, &()); cursor.seek(&point, Bias::Right, &());
let overshoot = point.0 - cursor.start().display.lines; let overshoot = point.0 - cursor.seek_start().0;
self.buffer self.buffer.to_offset(*cursor.start() + overshoot)
.to_offset(cursor.start().buffer.lines + overshoot)
} }
#[cfg(test)] #[cfg(test)]
pub fn clip_offset(&self, offset: DisplayOffset, bias: Bias) -> DisplayOffset { pub fn clip_offset(&self, offset: DisplayOffset, bias: Bias) -> DisplayOffset {
let mut cursor = self.transforms.cursor::<DisplayOffset, TransformSummary>(); let mut cursor = self.transforms.cursor::<DisplayOffset, usize>();
cursor.seek(&offset, Bias::Right, &()); cursor.seek(&offset, Bias::Right, &());
if let Some(transform) = cursor.item() { if let Some(transform) = cursor.item() {
let transform_start = cursor.start().display.bytes; let transform_start = cursor.seek_start().0;
if transform.display_text.is_some() { if transform.display_text.is_some() {
if offset.0 == transform_start || matches!(bias, Bias::Left) { if offset.0 == transform_start || matches!(bias, Bias::Left) {
DisplayOffset(transform_start) DisplayOffset(transform_start)
} else { } else {
DisplayOffset(cursor.end(&()).display.bytes) DisplayOffset(cursor.seek_end(&()).0)
} }
} else { } else {
let overshoot = offset.0 - transform_start; let overshoot = offset.0 - transform_start;
let buffer_offset = cursor.start().buffer.bytes + overshoot; let buffer_offset = cursor.start() + overshoot;
let clipped_buffer_offset = self.buffer.clip_offset(buffer_offset, bias); let clipped_buffer_offset = self.buffer.clip_offset(buffer_offset, bias);
DisplayOffset( DisplayOffset(
(offset.0 as isize + (clipped_buffer_offset as isize - buffer_offset as isize)) (offset.0 as isize + (clipped_buffer_offset as isize - buffer_offset as isize))
@ -531,19 +527,19 @@ impl FoldMapSnapshot {
} }
pub fn clip_point(&self, point: DisplayPoint, bias: Bias) -> DisplayPoint { pub fn clip_point(&self, point: DisplayPoint, bias: Bias) -> DisplayPoint {
let mut cursor = self.transforms.cursor::<DisplayPoint, TransformSummary>(); let mut cursor = self.transforms.cursor::<DisplayPoint, Point>();
cursor.seek(&point, Bias::Right, &()); cursor.seek(&point, Bias::Right, &());
if let Some(transform) = cursor.item() { if let Some(transform) = cursor.item() {
let transform_start = cursor.start().display.lines; let transform_start = cursor.seek_start().0;
if transform.display_text.is_some() { if transform.display_text.is_some() {
if point.0 == transform_start || matches!(bias, Bias::Left) { if point.0 == transform_start || matches!(bias, Bias::Left) {
DisplayPoint(transform_start) DisplayPoint(transform_start)
} else { } else {
DisplayPoint(cursor.end(&()).display.lines) DisplayPoint(cursor.seek_end(&()).0)
} }
} else { } else {
let overshoot = point.0 - transform_start; let overshoot = point.0 - transform_start;
let buffer_position = cursor.start().buffer.lines + overshoot; let buffer_position = *cursor.start() + overshoot;
let clipped_buffer_position = self.buffer.clip_point(buffer_position, bias); let clipped_buffer_position = self.buffer.clip_point(buffer_position, bias);
DisplayPoint::new( DisplayPoint::new(
point.row(), point.row(),
@ -681,7 +677,7 @@ impl<'a> sum_tree::Dimension<'a, FoldSummary> for usize {
} }
pub struct BufferRows<'a> { pub struct BufferRows<'a> {
cursor: Cursor<'a, Transform, DisplayPoint, TransformSummary>, cursor: Cursor<'a, Transform, DisplayPoint, Point>,
display_point: Point, display_point: Point,
} }
@ -689,7 +685,7 @@ impl<'a> Iterator for BufferRows<'a> {
type Item = u32; type Item = u32;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
while self.display_point > self.cursor.end(&()).display.lines { while self.display_point > self.cursor.seek_end(&()).0 {
self.cursor.next(&()); self.cursor.next(&());
if self.cursor.item().is_none() { if self.cursor.item().is_none() {
// TODO: Return a bool from next? // TODO: Return a bool from next?
@ -698,8 +694,8 @@ impl<'a> Iterator for BufferRows<'a> {
} }
if self.cursor.item().is_some() { if self.cursor.item().is_some() {
let overshoot = self.display_point - self.cursor.start().display.lines; let overshoot = self.display_point - self.cursor.seek_start().0;
let buffer_point = self.cursor.start().buffer.lines + overshoot; let buffer_point = *self.cursor.start() + overshoot;
self.display_point.row += 1; self.display_point.row += 1;
Some(buffer_point.row) Some(buffer_point.row)
} else { } else {
@ -709,7 +705,7 @@ impl<'a> Iterator for BufferRows<'a> {
} }
pub struct Chunks<'a> { pub struct Chunks<'a> {
transform_cursor: Cursor<'a, Transform, DisplayOffset, TransformSummary>, transform_cursor: Cursor<'a, Transform, DisplayOffset, usize>,
buffer_chunks: buffer::Chunks<'a>, buffer_chunks: buffer::Chunks<'a>,
buffer_offset: usize, buffer_offset: usize,
} }
@ -730,7 +726,7 @@ impl<'a> Iterator for Chunks<'a> {
self.buffer_offset += transform.summary.buffer.bytes; self.buffer_offset += transform.summary.buffer.bytes;
self.buffer_chunks.seek(self.buffer_offset); self.buffer_chunks.seek(self.buffer_offset);
while self.buffer_offset >= self.transform_cursor.end(&()).buffer.bytes while self.buffer_offset >= self.transform_cursor.end(&())
&& self.transform_cursor.item().is_some() && self.transform_cursor.item().is_some()
{ {
self.transform_cursor.next(&()); self.transform_cursor.next(&());
@ -745,7 +741,7 @@ impl<'a> Iterator for Chunks<'a> {
chunk = &chunk[offset_in_chunk..]; chunk = &chunk[offset_in_chunk..];
// Truncate the chunk so that it ends at the next fold. // Truncate the chunk so that it ends at the next fold.
let region_end = self.transform_cursor.end(&()).buffer.bytes - self.buffer_offset; let region_end = self.transform_cursor.end(&()) - self.buffer_offset;
if chunk.len() >= region_end { if chunk.len() >= region_end {
chunk = &chunk[0..region_end]; chunk = &chunk[0..region_end];
self.transform_cursor.next(&()); self.transform_cursor.next(&());
@ -762,7 +758,7 @@ impl<'a> Iterator for Chunks<'a> {
} }
pub struct HighlightedChunks<'a> { pub struct HighlightedChunks<'a> {
transform_cursor: Cursor<'a, Transform, DisplayOffset, TransformSummary>, transform_cursor: Cursor<'a, Transform, DisplayOffset, usize>,
buffer_chunks: buffer::HighlightedChunks<'a>, buffer_chunks: buffer::HighlightedChunks<'a>,
buffer_chunk: Option<(usize, &'a str, StyleId)>, buffer_chunk: Option<(usize, &'a str, StyleId)>,
buffer_offset: usize, buffer_offset: usize,
@ -785,7 +781,7 @@ impl<'a> Iterator for HighlightedChunks<'a> {
self.buffer_offset += transform.summary.buffer.bytes; self.buffer_offset += transform.summary.buffer.bytes;
self.buffer_chunks.seek(self.buffer_offset); self.buffer_chunks.seek(self.buffer_offset);
while self.buffer_offset >= self.transform_cursor.end(&()).buffer.bytes while self.buffer_offset >= self.transform_cursor.end(&())
&& self.transform_cursor.item().is_some() && self.transform_cursor.item().is_some()
{ {
self.transform_cursor.next(&()); self.transform_cursor.next(&());
@ -809,7 +805,7 @@ impl<'a> Iterator for HighlightedChunks<'a> {
chunk = &chunk[offset_in_chunk..]; chunk = &chunk[offset_in_chunk..];
// Truncate the chunk so that it ends at the next fold. // Truncate the chunk so that it ends at the next fold.
let region_end = self.transform_cursor.end(&()).buffer.bytes - self.buffer_offset; let region_end = self.transform_cursor.end(&()) - self.buffer_offset;
if chunk.len() >= region_end { if chunk.len() >= region_end {
chunk = &chunk[0..region_end]; chunk = &chunk[0..region_end];
self.transform_cursor.next(&()); self.transform_cursor.next(&());

View file

@ -49,6 +49,16 @@ where
&self.seek_dimension &self.seek_dimension
} }
pub fn seek_end(&self, cx: &<T::Summary as Summary>::Context) -> S {
if let Some(item_summary) = self.item_summary() {
let mut end = self.seek_start().clone();
end.add_summary(item_summary, cx);
end
} else {
self.seek_start().clone()
}
}
pub fn start(&self) -> &U { pub fn start(&self) -> &U {
&self.sum_dimension &self.sum_dimension
} }

View file

@ -1290,8 +1290,8 @@ impl WorktreeHandle for ModelHandle<Worktree> {
} }
pub enum FileIter<'a> { pub enum FileIter<'a> {
All(Cursor<'a, Entry, FileCount, FileCount>), All(Cursor<'a, Entry, FileCount, ()>),
Visible(Cursor<'a, Entry, VisibleFileCount, VisibleFileCount>), Visible(Cursor<'a, Entry, VisibleFileCount, ()>),
} }
impl<'a> FileIter<'a> { impl<'a> FileIter<'a> {
@ -1310,11 +1310,11 @@ impl<'a> FileIter<'a> {
fn next_internal(&mut self) { fn next_internal(&mut self) {
match self { match self {
Self::All(cursor) => { Self::All(cursor) => {
let ix = *cursor.start(); let ix = *cursor.seek_start();
cursor.seek_forward(&FileCount(ix.0 + 1), Bias::Right, &()); cursor.seek_forward(&FileCount(ix.0 + 1), Bias::Right, &());
} }
Self::Visible(cursor) => { Self::Visible(cursor) => {
let ix = *cursor.start(); let ix = *cursor.seek_start();
cursor.seek_forward(&VisibleFileCount(ix.0 + 1), Bias::Right, &()); cursor.seek_forward(&VisibleFileCount(ix.0 + 1), Bias::Right, &());
} }
} }