Merge branch 'master' into buffer-per-inode

This commit is contained in:
Nathan Sobo
2021-05-03 20:47:28 -06:00
6 changed files with 1665 additions and 161 deletions
+26
View File
@@ -34,6 +34,13 @@ impl DisplayMap {
}
}
pub fn folds_in_range<T>(&self, range: Range<T>, app: &AppContext) -> Result<&[Range<Anchor>]>
where
T: ToOffset,
{
self.fold_map.folds_in_range(range, app)
}
pub fn fold<T: ToOffset>(
&mut self,
ranges: impl IntoIterator<Item = Range<T>>,
@@ -67,6 +74,20 @@ impl DisplayMap {
Ok(chars.take_while(|c| *c != '\n').collect())
}
pub fn line_indent(&self, display_row: u32, app: &AppContext) -> Result<(u32, bool)> {
let mut indent = 0;
let mut is_blank = true;
for c in self.chars_at(DisplayPoint::new(display_row, 0), app)? {
if c == ' ' {
indent += 1;
} else {
is_blank = c == '\n';
break;
}
}
Ok((indent, is_blank))
}
pub fn chars_at<'a>(&'a self, point: DisplayPoint, app: &'a AppContext) -> Result<Chars<'a>> {
let column = point.column() as usize;
let (point, to_next_stop) = point.collapse_tabs(self, Bias::Left, app)?;
@@ -165,6 +186,11 @@ impl DisplayPoint {
.to_buffer_point(self.collapse_tabs(map, bias, app)?.0))
}
pub fn to_buffer_offset(self, map: &DisplayMap, bias: Bias, app: &AppContext) -> Result<usize> {
map.fold_map
.to_buffer_offset(self.collapse_tabs(map, bias, app)?.0, app)
}
fn expand_tabs(mut self, map: &DisplayMap, app: &AppContext) -> Result<Self> {
let chars = map
.fold_map