Introduce a struct for spanned_rows result

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Nathan Sobo
2021-07-30 09:50:28 -07:00
committed by Max Brunsfeld
co-authored by Antonio Scandurra
parent 029460bf7e
commit a6a8f4fd81
2 changed files with 37 additions and 18 deletions
+10 -5
View File
@@ -17,6 +17,11 @@ pub enum SelectionGoal {
ColumnRange { start: u32, end: u32 },
}
pub struct SpannedRows {
pub buffer_rows: Range<u32>,
pub display_rows: Range<u32>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Selection {
pub id: usize,
@@ -93,7 +98,7 @@ impl Selection {
&self,
include_end_if_at_line_start: bool,
map: &DisplayMapSnapshot,
) -> (Range<u32>, Range<u32>) {
) -> SpannedRows {
let display_start = self.start.to_display_point(map, Bias::Left);
let mut display_end = self.end.to_display_point(map, Bias::Right);
if !include_end_if_at_line_start
@@ -107,9 +112,9 @@ impl Selection {
let (display_start, buffer_start) = map.prev_row_boundary(display_start);
let (display_end, buffer_end) = map.next_row_boundary(display_end);
(
buffer_start.row..buffer_end.row + 1,
display_start.row()..display_end.row() + 1,
)
SpannedRows {
buffer_rows: buffer_start.row..buffer_end.row + 1,
display_rows: display_start.row()..display_end.row() + 1,
}
}
}