Tweak terminal width trimming

Properly account for left margin when setting terminal width through
CLI flag and don't trim code by default if we can't get the terminal's
dimensions.
This commit is contained in:
Esteban Küber 2019-08-30 19:47:21 -07:00
parent 78f62c6190
commit bf90154410

View File

@ -1304,11 +1304,11 @@ impl EmitterWriter {
};
let column_width = if let Some(width) = self.terminal_width {
width
max(width, code_offset) - code_offset
} else if self.ui_testing {
140
} else {
term_size::dimensions().map(|(w, _)| w - code_offset).unwrap_or(140)
term_size::dimensions().map(|(w, _)| w - code_offset).unwrap_or(std::usize::MAX)
};
let margin = Margin::new(