Skip to content

Commit

Permalink
refactor: Rename variable
Browse files Browse the repository at this point in the history
		The fold chaining is to find max line number rather than line number width
  • Loading branch information
chengr4 committed Aug 21, 2024
1 parent e205bbd commit 1180660
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/renderer/display_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ impl<'a> fmt::Debug for DisplayList<'a> {

impl<'a> Display for DisplayList<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let lineno_width = self.body.iter().fold(0, |max, set| {
let max_lineno = self.body.iter().fold(0, |max, set| {
set.display_lines.iter().fold(max, |max, line| match line {
DisplayLine::Source { lineno, .. } => cmp::max(lineno.unwrap_or(0), max),
_ => max,
})
});
let lineno_width = if lineno_width == 0 {
let lineno_width = if max_lineno == 0 {
1
} else if self.anonymized_line_numbers {
ANONYMIZED_LINE_NUM.len()
} else {
((lineno_width as f64).log10().floor() as usize) + 1
((max_lineno as f64).log10().floor() as usize) + 1
};

let multiline_depth = self.body.iter().fold(0, |max, set| {
Expand Down

0 comments on commit 1180660

Please sign in to comment.