summaryrefslogtreecommitdiffstats
path: root/src/delta.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-06-26 12:56:36 -0400
committerDan Davison <dandavison7@gmail.com>2020-06-26 13:50:49 -0400
commit8c1ed7b2dad3b83196ab9272174d6452b6fc75f2 (patch)
treeece9210fba34b8423ea00001c2d202d5ea8bec2a /src/delta.rs
parenta5705f305d3d26e0d522e9bd8580f7c395ba5ebd (diff)
Bugfix: fix highlighting bug (no test coverage)
Diffstat (limited to 'src/delta.rs')
-rw-r--r--src/delta.rs22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/delta.rs b/src/delta.rs
index 009bb64f..e00f4491 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -526,22 +526,14 @@ 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. If we are retaining them
- // (--keep-plus-minus-markers), then we substitute it for a space now, so that it is not
- // present during syntax highlighting, and reinstate it when emitting the line in
- // Painter::paint_lines. If we not retaining them, then we drop it now, and
- // Painter::paint_lines doesn't inject anything.
+ // The first column contains a -/+/space character, added by git. We substitute it for a
+ // space now, so that it is not present during syntax highlighting. When emitting the line
+ // in Painter::paint_lines, we drop the space (unless --keep-plus-minus-markers is in
+ // effect in which case we replace it with the appropriate marker).
+ // TODO: Things should, but do not, work if this leading space is omitted at this stage.
+ // See comment in align::Alignment::new.
line.next();
- format!(
- "{}{}{}",
- if config.keep_plus_minus_markers {
- " "
- } else {
- ""
- },
- expand_tabs(line, config.tab_width),
- terminator
- )
+ format!(" {}{}", expand_tabs(line, config.tab_width), terminator)
} else {
terminator.to_string()
}