Replace rightmost_point with righmost_row

This commit is contained in:
Antonio Scandurra 2021-05-20 12:35:24 +02:00
parent 96538354b3
commit ed57ffe5fa
4 changed files with 20 additions and 11 deletions

View file

@ -520,7 +520,7 @@ impl LayoutState {
layout_cache: &TextLayoutCache, layout_cache: &TextLayoutCache,
app: &AppContext, app: &AppContext,
) -> f32 { ) -> f32 {
let row = view.rightmost_point(app).row(); let row = view.rightmost_row(app);
let longest_line_width = view let longest_line_width = view
.layout_line(row, font_cache, layout_cache, app) .layout_line(row, font_cache, layout_cache, app)
.unwrap() .unwrap()

View file

@ -2015,8 +2015,8 @@ impl BufferView {
self.display_map.line_len(display_row, ctx) self.display_map.line_len(display_row, ctx)
} }
pub fn rightmost_point(&self, ctx: &AppContext) -> DisplayPoint { pub fn rightmost_row(&self, ctx: &AppContext) -> u32 {
self.display_map.rightmost_point(ctx) self.display_map.rightmost_row(ctx)
} }
pub fn max_point(&self, ctx: &AppContext) -> DisplayPoint { pub fn max_point(&self, ctx: &AppContext) -> DisplayPoint {

View file

@ -67,8 +67,8 @@ impl FoldMap {
DisplayPoint(self.sync(ctx).summary().display.lines) DisplayPoint(self.sync(ctx).summary().display.lines)
} }
pub fn rightmost_point(&self, ctx: &AppContext) -> DisplayPoint { pub fn rightmost_row(&self, ctx: &AppContext) -> u32 {
DisplayPoint(self.sync(ctx).summary().display.rightmost_point) self.sync(ctx).summary().display.rightmost_point.row
} }
pub fn folds_in_range<'a, T>( pub fn folds_in_range<'a, T>(
@ -989,7 +989,13 @@ mod tests {
assert_eq!(line_len, line.len() as u32); assert_eq!(line_len, line.len() as u32);
} }
let rightmost_point = map.rightmost_point(app.as_ref()); let rightmost_row = map.rightmost_row(app.as_ref());
let rightmost_char_column = expected_text
.split('\n')
.nth(rightmost_row as usize)
.unwrap()
.chars()
.count();
let mut display_point = DisplayPoint::new(0, 0); let mut display_point = DisplayPoint::new(0, 0);
let mut display_offset = DisplayOffset(0); let mut display_offset = DisplayOffset(0);
let mut char_column = 0; let mut char_column = 0;
@ -1024,10 +1030,13 @@ mod tests {
char_column += 1; char_column += 1;
} }
display_offset.0 += c.len_utf8(); display_offset.0 += c.len_utf8();
if char_column > rightmost_point.column() { if char_column > rightmost_char_column {
panic!( panic!(
"invalid rightmost point {:?}, found point {:?} (char column: {})", "invalid rightmost row {:?} (chars {}), found row {:?} (chars: {})",
rightmost_point, display_point, char_column rightmost_row,
rightmost_char_column,
display_point.row(),
char_column
); );
} }
} }

View file

@ -109,8 +109,8 @@ impl DisplayMap {
self.fold_map.max_point(ctx).expand_tabs(self, ctx) self.fold_map.max_point(ctx).expand_tabs(self, ctx)
} }
pub fn rightmost_point(&self, ctx: &AppContext) -> DisplayPoint { pub fn rightmost_row(&self, ctx: &AppContext) -> u32 {
self.fold_map.rightmost_point(ctx) self.fold_map.rightmost_row(ctx)
} }
pub fn anchor_before(&self, point: DisplayPoint, bias: Bias, app: &AppContext) -> Anchor { pub fn anchor_before(&self, point: DisplayPoint, bias: Bias, app: &AppContext) -> Anchor {