summaryrefslogtreecommitdiffstats
path: root/src/paint.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-08-06 17:11:14 -0400
committerDan Davison <dandavison7@gmail.com>2020-08-06 23:34:59 -0400
commit25caec1d7281d02f7461c3381415ed5987fd60a7 (patch)
treeef12d6a77a512310e29da7c8b2ea74d768232e49 /src/paint.rs
parent1ba3feaf55f3da2535d9ac2f61d31bd99843d4a3 (diff)
Do not send artificial leading space to syntax highlighter
Fixes #275
Diffstat (limited to 'src/paint.rs')
-rw-r--r--src/paint.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/paint.rs b/src/paint.rs
index a40a8e82..0fb0b193 100644
--- a/src/paint.rs
+++ b/src/paint.rs
@@ -472,7 +472,11 @@ impl<'a> Painter<'a> {
if fake {
line_sections.push(vec![(config.null_syntect_style, line.as_str())])
} else {
- line_sections.push(highlighter.highlight(line, &config.syntax_set))
+ // The first character is a space injected by delta. See comment in
+ // Painter:::prepare.
+ let mut this_line_sections = highlighter.highlight(&line[1..], &config.syntax_set);
+ this_line_sections.insert(0, (config.null_syntect_style, &line[..1]));
+ line_sections.push(this_line_sections);
}
}
line_sections