Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d445d69

Browse files
committedAug 20, 2024·
refactor: Rename variable
The fold chaining is to find max line number rather than line number width
1 parent 4ba7683 commit d445d69

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎src/renderer/display_list.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ impl<'a> fmt::Debug for DisplayList<'a> {
7272

7373
impl<'a> Display for DisplayList<'a> {
7474
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
75-
let lineno_width = self.body.iter().fold(0, |max, set| {
75+
let max_lineno = self.body.iter().fold(0, |max, set| {
7676
set.display_lines.iter().fold(max, |max, line| match line {
7777
DisplayLine::Source { lineno, .. } => cmp::max(lineno.unwrap_or(0), max),
7878
_ => max,
7979
})
8080
});
81-
let lineno_width = if lineno_width == 0 {
82-
lineno_width + 1
81+
let lineno_width = if max_lineno == 0 {
82+
1
8383
} else if self.anonymized_line_numbers {
8484
ANONYMIZED_LINE_NUM.len()
8585
} else {
86-
((lineno_width as f64).log10().floor() as usize) + 1
86+
((max_lineno as f64).log10().floor() as usize) + 1
8787
};
8888

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

0 commit comments

Comments
 (0)
Please sign in to comment.