on master help sign in
Fix #117
commit900f61032d36eb896a0fc3baf5bd630e38c04a0d authoreth-p <32112321+eth-p@users.noreply.github.com> dateTue 15 May 2018, 14:09 (8 years ago) parentd0ca566
1 file changed+8−1
src/printer.rs+8−1
src/printer.rs+8−1
@@ -38,7 +38,7 @@ impl<'a> Printer<'a> {
3838 decorations.push(Box::new(LineChangesDecoration::new(&colors)));
3939 }
4040
41− let panel_width: usize =
41+ let mut panel_width: usize =
4242 decorations.len() + decorations.iter().fold(0, |a, x| a + x.width());
4343
4444 // The grid border decoration isn't added until after the panel_width calculation, since the
@@ -48,6 +48,13 @@ impl<'a> Printer<'a> {
4848 decorations.push(Box::new(GridBorderDecoration::new(&colors)));
4949 }
5050
51+ // Disable the panel if the terminal is too small (i.e. can't fit 5 characters with the
52+ // panel showing).
53+ if config.term_width < (decorations.len() + decorations.iter().fold(0, |a, x| a + x.width())) + 5 {
54+ decorations.clear();
55+ panel_width = 0;
56+ }
57+
5158 // Create printer.
5259 Printer {
5360 panel_width,