Rename `rightmost_{row,chars}` to `longest_{row,chars}`

Antonio Scandurra and Nathan Sobo created

Co-Authored-By: Nathan Sobo <nathan@zed.dev>

Change summary

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(-)

Detailed changes

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

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 {

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()

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 {

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
                         );

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 {