From b42f5142f74129df4afb7aae116bd5e55064ea00 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 20 May 2021 16:32:09 +0200 Subject: [PATCH] Rename `rightmost_{row,chars}` to `longest_{row,chars}` Co-Authored-By: Nathan Sobo --- zed/src/editor/buffer/mod.rs | 20 ++++++++--------- zed/src/editor/buffer/rope.rs | 30 +++++++++++++------------- zed/src/editor/buffer_element.rs | 2 +- zed/src/editor/buffer_view.rs | 4 ++-- zed/src/editor/display_map/fold_map.rs | 22 +++++++++---------- zed/src/editor/display_map/mod.rs | 4 ++-- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/zed/src/editor/buffer/mod.rs b/zed/src/editor/buffer/mod.rs index ddf40a983293df16dee765f718753cf73563ac0f..1b458388bc1cf26495fd97a22ce82bed935528aa 100644 --- a/zed/src/editor/buffer/mod.rs +++ b/zed/src/editor/buffer/mod.rs @@ -2525,8 +2525,8 @@ mod tests { lines: Point::new(1, 0), first_line_chars: 1, last_line_chars: 0, - rightmost_row: 0, - rightmost_row_chars: 1, + longest_row: 0, + longest_row_chars: 1, } ); assert_eq!( @@ -2536,8 +2536,8 @@ mod tests { lines: Point::new(3, 0), first_line_chars: 1, last_line_chars: 0, - rightmost_row: 2, - rightmost_row_chars: 4, + longest_row: 2, + longest_row_chars: 4, } ); assert_eq!( @@ -2547,8 +2547,8 @@ mod tests { lines: Point::new(4, 1), first_line_chars: 2, last_line_chars: 1, - rightmost_row: 3, - rightmost_row_chars: 6, + longest_row: 3, + longest_row_chars: 6, } ); assert_eq!( @@ -2558,8 +2558,8 @@ mod tests { lines: Point::new(4, 3), first_line_chars: 2, last_line_chars: 3, - rightmost_row: 3, - rightmost_row_chars: 6, + longest_row: 3, + longest_row_chars: 6, } ); assert_eq!( @@ -2569,8 +2569,8 @@ mod tests { lines: Point::new(2, 3), first_line_chars: 4, last_line_chars: 3, - rightmost_row: 1, - rightmost_row_chars: 6, + longest_row: 1, + longest_row_chars: 6, } ); buffer diff --git a/zed/src/editor/buffer/rope.rs b/zed/src/editor/buffer/rope.rs index 83c5ee4d5dec7707393f41d572562384529d160d..101620f6c269cde2600c2edddb1f2817c1356297 100644 --- a/zed/src/editor/buffer/rope.rs +++ b/zed/src/editor/buffer/rope.rs @@ -392,8 +392,8 @@ pub struct TextSummary { pub lines: Point, pub first_line_chars: u32, pub last_line_chars: u32, - pub rightmost_row: u32, - pub rightmost_row_chars: u32, + pub longest_row: u32, + pub longest_row_chars: u32, } impl<'a> From<&'a str> for TextSummary { @@ -401,8 +401,8 @@ impl<'a> From<&'a str> for TextSummary { let mut lines = Point::new(0, 0); let mut first_line_chars = 0; let mut last_line_chars = 0; - let mut rightmost_row = 0; - let mut rightmost_row_chars = 0; + let mut longest_row = 0; + let mut longest_row_chars = 0; for c in text.chars() { if c == '\n' { lines.row += 1; @@ -417,9 +417,9 @@ impl<'a> From<&'a str> for TextSummary { first_line_chars = last_line_chars; } - if last_line_chars > rightmost_row_chars { - rightmost_row = lines.row; - rightmost_row_chars = last_line_chars; + if last_line_chars > longest_row_chars { + longest_row = lines.row; + longest_row_chars = last_line_chars; } } @@ -428,8 +428,8 @@ impl<'a> From<&'a str> for TextSummary { lines, first_line_chars, last_line_chars, - rightmost_row, - rightmost_row_chars, + longest_row, + longest_row_chars, } } } @@ -445,13 +445,13 @@ impl sum_tree::Summary for TextSummary { impl<'a> std::ops::AddAssign<&'a Self> for TextSummary { fn add_assign(&mut self, other: &'a Self) { let joined_chars = self.last_line_chars + other.first_line_chars; - if joined_chars > self.rightmost_row_chars { - self.rightmost_row = self.lines.row; - self.rightmost_row_chars = joined_chars; + if joined_chars > self.longest_row_chars { + self.longest_row = self.lines.row; + self.longest_row_chars = joined_chars; } - if other.rightmost_row_chars > self.rightmost_row_chars { - self.rightmost_row = self.lines.row + other.rightmost_row; - self.rightmost_row_chars = other.rightmost_row_chars; + if other.longest_row_chars > self.longest_row_chars { + self.longest_row = self.lines.row + other.longest_row; + self.longest_row_chars = other.longest_row_chars; } if self.lines.row == 0 { diff --git a/zed/src/editor/buffer_element.rs b/zed/src/editor/buffer_element.rs index b38d6eed2949728e995c74b9814abf41d20e2eaf..ac5354f95ceb78933ea6de64db2b6f4863dd8368 100644 --- a/zed/src/editor/buffer_element.rs +++ b/zed/src/editor/buffer_element.rs @@ -520,7 +520,7 @@ impl LayoutState { layout_cache: &TextLayoutCache, app: &AppContext, ) -> f32 { - let row = view.rightmost_row(app); + let row = view.longest_row(app); let longest_line_width = view .layout_line(row, font_cache, layout_cache, app) .unwrap() diff --git a/zed/src/editor/buffer_view.rs b/zed/src/editor/buffer_view.rs index 52fc45f87b8f919d8ae57c530eb9ce008a43f319..57dbb2992d6f78e1ea5035ad95f0086331c401ae 100644 --- a/zed/src/editor/buffer_view.rs +++ b/zed/src/editor/buffer_view.rs @@ -2015,8 +2015,8 @@ impl BufferView { self.display_map.line_len(display_row, ctx) } - pub fn rightmost_row(&self, ctx: &AppContext) -> u32 { - self.display_map.rightmost_row(ctx) + pub fn longest_row(&self, ctx: &AppContext) -> u32 { + self.display_map.longest_row(ctx) } pub fn max_point(&self, ctx: &AppContext) -> DisplayPoint { diff --git a/zed/src/editor/display_map/fold_map.rs b/zed/src/editor/display_map/fold_map.rs index 5494d61c9a51fd064c2374f80916fec005b6e1ea..4cfcd8933704892bf8e831df4d03bceea63b2d70 100644 --- a/zed/src/editor/display_map/fold_map.rs +++ b/zed/src/editor/display_map/fold_map.rs @@ -67,8 +67,8 @@ impl FoldMap { DisplayPoint(self.sync(ctx).summary().display.lines) } - pub fn rightmost_row(&self, ctx: &AppContext) -> u32 { - self.sync(ctx).summary().display.rightmost_row + pub fn longest_row(&self, ctx: &AppContext) -> u32 { + self.sync(ctx).summary().display.longest_row } pub fn folds_in_range<'a, T>( @@ -340,8 +340,8 @@ impl FoldMap { lines, first_line_chars: chars, last_line_chars: chars, - rightmost_row: 0, - rightmost_row_chars: chars, + longest_row: 0, + longest_row_chars: chars, }, buffer: buffer.text_summary_for_range(fold.start..fold.end), }, @@ -990,10 +990,10 @@ mod tests { assert_eq!(line_len, line.len() as u32); } - let rightmost_row = map.rightmost_row(app.as_ref()); - let rightmost_char_column = expected_text + let longest_row = map.longest_row(app.as_ref()); + let longest_char_column = expected_text .split('\n') - .nth(rightmost_row as usize) + .nth(longest_row as usize) .unwrap() .chars() .count(); @@ -1031,11 +1031,11 @@ mod tests { char_column += 1; } display_offset.0 += c.len_utf8(); - if char_column > rightmost_char_column { + if char_column > longest_char_column { panic!( - "invalid rightmost row {:?} (chars {}), found row {:?} (chars: {})", - rightmost_row, - rightmost_char_column, + "invalid longest row {:?} (chars {}), found row {:?} (chars: {})", + longest_row, + longest_char_column, display_point.row(), char_column ); diff --git a/zed/src/editor/display_map/mod.rs b/zed/src/editor/display_map/mod.rs index 81c27f349fb2f88fc663ec156b135774eec2360f..b2874a5805822830fbcd3ebf9ae64a688ac46c90 100644 --- a/zed/src/editor/display_map/mod.rs +++ b/zed/src/editor/display_map/mod.rs @@ -109,8 +109,8 @@ impl DisplayMap { self.fold_map.max_point(ctx).expand_tabs(self, ctx) } - pub fn rightmost_row(&self, ctx: &AppContext) -> u32 { - self.fold_map.rightmost_row(ctx) + pub fn longest_row(&self, ctx: &AppContext) -> u32 { + self.fold_map.longest_row(ctx) } pub fn anchor_before(&self, point: DisplayPoint, bias: Bias, app: &AppContext) -> Anchor {