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

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra
2021-05-20 16:32:09 +02:00
co-authored by Nathan Sobo
parent 86199c588f
commit b42f5142f7
6 changed files with 41 additions and 41 deletions
+10 -10
View File
@@ -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
+15 -15
View File
@@ -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 {