Implement select_larger_syntax_node for buffer

This commit is contained in:
Antonio Scandurra
2021-05-28 13:25:09 +02:00
parent 6992c19aee
commit 23d1d91414
4 changed files with 67 additions and 1 deletions
+12
View File
@@ -192,6 +192,18 @@ impl FoldMap {
})
}
pub fn intersects_fold<T>(&self, offset: T, ctx: &AppContext) -> bool
where
T: ToOffset,
{
let buffer = self.buffer.read(ctx);
let offset = offset.to_offset(buffer);
let transforms = self.sync(ctx);
let mut cursor = transforms.cursor::<usize, usize>();
cursor.seek(&offset, SeekBias::Right, &());
cursor.item().map_or(false, |t| t.display_text.is_some())
}
pub fn is_line_folded(&self, display_row: u32, ctx: &AppContext) -> bool {
let transforms = self.sync(ctx);
let mut cursor = transforms.cursor::<DisplayPoint, DisplayPoint>();
+4
View File
@@ -57,6 +57,10 @@ impl DisplayMap {
self.fold_map.unfold(ranges, ctx)
}
pub fn intersects_fold<T: ToOffset>(&self, offset: T, ctx: &AppContext) -> bool {
self.fold_map.intersects_fold(offset, ctx)
}
pub fn is_line_folded(&self, display_row: u32, ctx: &AppContext) -> bool {
self.fold_map.is_line_folded(display_row, ctx)
}