summaryrefslogtreecommitdiffstats
path: root/src/delta.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/delta.rs')
-rw-r--r--src/delta.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/delta.rs b/src/delta.rs
index 897b2f10..49dbb2d1 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -271,6 +271,7 @@ fn handle_hunk_meta_line(
)]],
&mut painter.output_buffer,
config,
+ "",
style::NO_BACKGROUND_COLOR_STYLE_MODIFIER,
false,
);
@@ -321,6 +322,7 @@ fn handle_hunk_line(painter: &mut Painter, line: &str, state: State, config: &Co
State::HunkPlus
}
_ => {
+ let is_empty = line.is_empty();
painter.paint_buffered_lines();
let line = prepare(&line, true, config);
let syntax_style_sections = Painter::get_line_syntax_style_sections(
@@ -334,6 +336,7 @@ fn handle_hunk_line(painter: &mut Painter, line: &str, state: State, config: &Co
vec![vec![(style::NO_BACKGROUND_COLOR_STYLE_MODIFIER, &line)]],
&mut painter.output_buffer,
config,
+ if is_empty { "" } else { " " },
style::NO_BACKGROUND_COLOR_STYLE_MODIFIER,
true,
);
@@ -352,8 +355,9 @@ fn prepare(line: &str, append_newline: bool, config: &Config) -> String {
if !line.is_empty() {
let mut line = line.graphemes(true);
- // The first column contains a -/+/space character, added by git. We skip it here and insert
- // a replacement space when formatting the line below.
+ // The first column contains a -/+/space character, added by git. We drop it now, so that
+ // it is not present during syntax highlighting, and inject a replacement when emitting the
+ // line.
line.next();
// Expand tabs as spaces.
@@ -365,7 +369,7 @@ fn prepare(line: &str, append_newline: bool, config: &Config) -> String {
} else {
line.collect::<String>()
};
- format!(" {}{}", output_line, terminator)
+ format!("{}{}", output_line, terminator)
} else {
terminator.to_string()
}
@@ -604,6 +608,7 @@ mod tests {
minus_emph_color: None,
plus_color: None,
plus_emph_color: None,
+ keep_plus_minus_markers: false,
theme: None,
highlight_removed: false,
commit_style: cli::SectionStyle::Plain,