File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -72,13 +72,7 @@ impl<'a> fmt::Debug for DisplayList<'a> {
7272
7373impl < ' a > Display for DisplayList < ' a > {
7474 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
75- let max_lineno = self . get_max_lineno ( ) ;
76- let lineno_width = match max_lineno {
77- None => 0 ,
78- Some ( _max) if self . anonymized_line_numbers => ANONYMIZED_LINE_NUM . len ( ) ,
79- Some ( 0 ) => 1 ,
80- Some ( max) => ( max as f64 ) . log10 ( ) . floor ( ) as usize + 1 ,
81- } ;
75+ let lineno_width = self . get_lineno_width ( ) ;
8276
8377 let multiline_depth = self . body . iter ( ) . fold ( 0 , |max, set| {
8478 set. display_lines . iter ( ) . fold ( max, |max2, line| match line {
@@ -152,6 +146,17 @@ impl<'a> DisplayList<'a> {
152146 } ) ;
153147 max_lineno
154148 }
149+
150+ fn get_lineno_width ( & self ) -> usize {
151+ let max_lineno = self . get_max_lineno ( ) ;
152+ let lineno_width = match max_lineno {
153+ None => 0 ,
154+ Some ( _max) if self . anonymized_line_numbers => ANONYMIZED_LINE_NUM . len ( ) ,
155+ Some ( 0 ) => 1 ,
156+ Some ( max) => ( max as f64 ) . log10 ( ) . floor ( ) as usize + 1 ,
157+ } ;
158+ lineno_width
159+ }
155160}
156161
157162#[ derive( Debug , PartialEq ) ]
You can’t perform that action at this time.
0 commit comments