diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-07-29 23:00:49 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-08-01 11:38:19 -0400 |
commit | d9a07679dfaf2b9c9b84187f3691aa93d8beca31 (patch) | |
tree | 05370847279730c98a9b40961780433dd1104aa0 /src/delta.rs | |
parent | cd7953c176c2bc71b34cc2aaa1618f6ab208538f (diff) |
Emit raw lines instead of explicitly handling --color-moved
Diffstat (limited to 'src/delta.rs')
-rw-r--r-- | src/delta.rs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/delta.rs b/src/delta.rs index 5b3de991..409c1df6 100644 --- a/src/delta.rs +++ b/src/delta.rs @@ -12,16 +12,16 @@ use crate::features; use crate::format; use crate::paint::Painter; use crate::parse; -use crate::style::DecorationStyle; +use crate::style::{self, DecorationStyle}; #[derive(Clone, Debug, PartialEq)] pub enum State { - CommitMeta, // In commit metadata section - FileMeta, // In diff metadata section, between (possible) commit metadata and first hunk - HunkHeader, // In hunk metadata line - HunkZero, // In hunk; unchanged line - HunkMinus(bool), // In hunk; removed line (is_moved) - HunkPlus(bool), // In hunk; added line (is_moved) + CommitMeta, // In commit metadata section + FileMeta, // In diff metadata section, between (possible) commit metadata and first hunk + HunkHeader, // In hunk metadata line + HunkZero, // In hunk; unchanged line + HunkMinus(Option<String>), // In hunk; removed line (raw_line) + HunkPlus(Option<String>), // In hunk; added line (raw_line) Unknown, } @@ -502,16 +502,28 @@ fn handle_hunk_line( if let State::HunkPlus(_) = state { painter.paint_buffered_minus_and_plus_lines(); } - let is_moved = !config.raw_expected_minus_style.is_applied_to(raw_line); - let state = State::HunkMinus(is_moved); + let state = if style::line_has_style_other_than( + raw_line, + [*style::GIT_DEFAULT_MINUS_STYLE, config.git_minus_style].iter(), + ) { + State::HunkMinus(Some(painter.prepare_raw_line(raw_line))) + } else { + State::HunkMinus(None) + }; painter .minus_lines .push((painter.prepare(&line, true), state.clone())); state } Some('+') => { - let is_moved = !config.raw_expected_plus_style.is_applied_to(raw_line); - let state = State::HunkPlus(is_moved); + let state = if style::line_has_style_other_than( + raw_line, + [*style::GIT_DEFAULT_PLUS_STYLE, config.git_plus_style].iter(), + ) { + State::HunkPlus(Some(painter.prepare_raw_line(raw_line))) + } else { + State::HunkPlus(None) + }; painter .plus_lines .push((painter.prepare(&line, true), state.clone())); |