summaryrefslogtreecommitdiffstats
path: root/src/paint.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2019-09-06 14:16:29 +0100
committerDan Davison <dandavison7@gmail.com>2019-09-06 14:33:04 +0100
commitb746962437ca9b64d9ac73f20a8d8bb72c5fad2e (patch)
tree4d088e041aefbcf5fd07a5fb42c42b047a18c002 /src/paint.rs
parent9b4fbbfac7c95b82db6691659bfa43878d279d3e (diff)
Fix hunk meta line decoration
Diffstat (limited to 'src/paint.rs')
-rw-r--r--src/paint.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/paint.rs b/src/paint.rs
index e081c7d6..bf873727 100644
--- a/src/paint.rs
+++ b/src/paint.rs
@@ -88,7 +88,7 @@ impl<'a> Painter<'a> {
diff_style_sections: Vec<Vec<(StyleModifier, &str)>>,
config: &config::Config,
background_style_modifier: StyleModifier,
- lines_have_terminating_newline_character: bool,
+ should_trim_newline_and_right_pad: bool,
) {
use std::fmt::Write;
for (syntax_sections, diff_sections) in
@@ -101,23 +101,24 @@ impl<'a> Painter<'a> {
text_width += text.graphemes(true).count();
}
}
- if lines_have_terminating_newline_character {
+ if should_trim_newline_and_right_pad {
// Remove the terminating newline whose presence was necessary for the syntax
// highlighter to work correctly.
output_buffer.truncate(output_buffer.len() - 1);
- }
- match config.width {
- Some(width) if width > text_width => {
- // Right pad to requested width with spaces.
- let background_style = config.no_style.apply(background_style_modifier);
- paint_text(
- &" ".repeat(width - text_width),
- background_style,
- output_buffer,
- )
- .unwrap();
+ // Right pad with background-highlighted white space.
+ match config.width {
+ Some(width) if width > text_width => {
+ // Right pad to requested width with spaces.
+ let background_style = config.no_style.apply(background_style_modifier);
+ paint_text(
+ &" ".repeat(width - text_width),
+ background_style,
+ output_buffer,
+ )
+ .unwrap();
+ }
+ _ => (),
}
- _ => (),
}
writeln!(output_buffer).unwrap();
}