diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-04-11 23:03:14 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-04-12 00:47:34 -0400 |
commit | c0ed54cefa987a9df29352653f6becd824434713 (patch) | |
tree | 538d6006e5c40e0b23f90adb312590b8d86bc69e /src/paint.rs | |
parent | defc0eadff002ba94269637f38f0e342ec823aff (diff) |
Horrible hack working around my failure to fix a bug properly
At the parent commit da473302, some lines are being incorrectly
truncated at word boundaries. It's something to do with an interaction
between (a) the changes made in da473302 in order to implement
--retain-plus-minus-markers, and (b) the logic in tokenize(). This
commit works around that by reinstating the leading space character
during tokenization and syntax highlighting, and then removing it
afterwards in a hacky way.
Diffstat (limited to 'src/paint.rs')
-rw-r--r-- | src/paint.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/paint.rs b/src/paint.rs index a65ff00d..6ae052b4 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -118,7 +118,14 @@ impl<'a> Painter<'a> { if prefix != "" { ansi_strings.push(background_ansi_style.paint(prefix)); } - for (style, text) in superimpose_style_sections(syntax_sections, diff_sections) { + let mut dropped_prefix = prefix == ""; // TODO: Hack + for (style, mut text) in superimpose_style_sections(syntax_sections, diff_sections) { + if !dropped_prefix { + if text.len() > 0 { + text.remove(0); + } + dropped_prefix = true; + } if config.width.is_some() { text_width += text.graphemes(true).count(); } |