@@ -146,12 +146,12 @@ impl Margin {
146
146
} else if self . label_right - self . span_left <= self . column_width {
147
147
// Attempt to fit the code window considering only the spans and labels.
148
148
let padding_left = ( self . column_width - ( self . label_right - self . span_left ) ) / 2 ;
149
- self . computed_left = self . span_left - padding_left;
149
+ self . computed_left = self . span_left . saturating_sub ( padding_left) ;
150
150
self . computed_right = self . computed_left + self . column_width ;
151
151
} else if self . span_right - self . span_left <= self . column_width {
152
152
// Attempt to fit the code window considering the spans and labels plus padding.
153
153
let padding_left = ( self . column_width - ( self . span_right - self . span_left ) ) / 5 * 2 ;
154
- self . computed_left = self . span_left - padding_left;
154
+ self . computed_left = self . span_left . saturating_sub ( padding_left) ;
155
155
self . computed_right = self . computed_left + self . column_width ;
156
156
} else { // Mostly give up but still don't show the full line.
157
157
self . computed_left = self . span_left ;
@@ -1304,11 +1304,13 @@ impl EmitterWriter {
1304
1304
} ;
1305
1305
1306
1306
let column_width = if let Some ( width) = self . terminal_width {
1307
- width
1307
+ width. saturating_sub ( code_offset )
1308
1308
} else if self . ui_testing {
1309
1309
140
1310
1310
} else {
1311
- term_size:: dimensions ( ) . map ( |( w, _) | w - code_offset) . unwrap_or ( 140 )
1311
+ term_size:: dimensions ( )
1312
+ . map ( |( w, _) | w. saturating_sub ( code_offset) )
1313
+ . unwrap_or ( std:: usize:: MAX )
1312
1314
} ;
1313
1315
1314
1316
let margin = Margin :: new (
0 commit comments