mirror of
https://github.com/sharkdp/bat
synced 2024-11-16 00:47:58 +00:00
Fix #117
This commit is contained in:
parent
d0ca566979
commit
900f61032d
1 changed files with 8 additions and 1 deletions
|
@ -38,7 +38,7 @@ impl<'a> Printer<'a> {
|
|||
decorations.push(Box::new(LineChangesDecoration::new(&colors)));
|
||||
}
|
||||
|
||||
let panel_width: usize =
|
||||
let mut panel_width: usize =
|
||||
decorations.len() + decorations.iter().fold(0, |a, x| a + x.width());
|
||||
|
||||
// The grid border decoration isn't added until after the panel_width calculation, since the
|
||||
|
@ -48,6 +48,13 @@ impl<'a> Printer<'a> {
|
|||
decorations.push(Box::new(GridBorderDecoration::new(&colors)));
|
||||
}
|
||||
|
||||
// Disable the panel if the terminal is too small (i.e. can't fit 5 characters with the
|
||||
// panel showing).
|
||||
if config.term_width < (decorations.len() + decorations.iter().fold(0, |a, x| a + x.width())) + 5 {
|
||||
decorations.clear();
|
||||
panel_width = 0;
|
||||
}
|
||||
|
||||
// Create printer.
|
||||
Printer {
|
||||
panel_width,
|
||||
|
|
Loading…
Reference in a new issue