diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-11-28 18:19:42 -0500 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-11-28 18:28:22 -0500 |
commit | a19945f3d921e8df642f4eb6d14978a1329598db (patch) | |
tree | 246c72431d47df02590d4601d4dfd3969068a2d6 | |
parent | 85367a6ab2e8db3fe5c348bd803f1d914a943b61 (diff) |
Fix right fill style on color-moved lines
Bug introduced at 7d2ac303573a444ec3e98657bd0bd6d11f562b21
-rw-r--r-- | src/paint.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/paint.rs b/src/paint.rs index a4253133..0df8d9c8 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -415,11 +415,17 @@ impl<'p> Painter<'p> { } } State::HunkMinus(Some(_)) | State::HunkPlus(Some(_)) => { - if !diff_sections.is_empty() { - diff_sections[diff_sections.len() - 1].0 - } else { - config.null_style - } + // Consider the following raw line, from git colorMoved: + // ␛[1;36m+␛[m␛[1;36mclass·X:·pass␛[m␊ The last style section returned by + // parse_style_sections will be a default style associated with the terminal newline + // character; we want the last "real" style. + diff_sections + .iter() + .rev() + .filter(|(_, s)| s != &"\n") + .map(|(style, _)| *style) + .next() + .unwrap_or(config.null_style) } State::Blame(_, _) => diff_sections[0].0, _ => config.null_style, |