Implement move_line_up and move_line_down

This does not restore folds yet.
This commit is contained in:
Antonio Scandurra
2021-05-03 11:37:36 +02:00
parent d499fb0d44
commit 8cd451f3ca
4 changed files with 188 additions and 11 deletions
+7
View File
@@ -169,6 +169,13 @@ impl FoldMap {
false
}
pub fn to_buffer_offset(&self, point: DisplayPoint, app: &AppContext) -> Result<usize> {
let mut cursor = self.transforms.cursor::<DisplayPoint, TransformSummary>();
cursor.seek(&point, SeekBias::Right);
let overshoot = point.0 - cursor.start().display.lines;
(cursor.start().buffer.lines + overshoot).to_offset(self.buffer.read(app))
}
pub fn to_display_offset(
&self,
point: DisplayPoint,
+5
View File
@@ -179,6 +179,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