summaryrefslogtreecommitdiffstats
path: root/src/delta.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-05-30 13:05:08 -0400
committerDan Davison <dandavison7@gmail.com>2020-05-30 16:55:38 -0400
commitc7a9bb77302b0df013250be4ac3d27d547a46502 (patch)
tree204901de0998d06c58712aa53959d4c0a3cd2f1d /src/delta.rs
parentf2902c4f7222666f4073fa2ae5e76efd329d73c9 (diff)
Refactor: config.get_style and delta::should_handle
Diffstat (limited to 'src/delta.rs')
-rw-r--r--src/delta.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/delta.rs b/src/delta.rs
index 7e5ecc1a..a56b1d21 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -113,9 +113,7 @@ where
} else if line.starts_with("@@") {
state = State::HunkHeader;
painter.set_highlighter();
- if !(config.hunk_header_style.is_raw
- && config.hunk_header_style.decoration_style == DecorationStyle::NoDecoration)
- {
+ if should_handle(&state, config) {
painter.emit()?;
handle_hunk_header_line(&mut painter, &line, &raw_line, config)?;
continue;
@@ -166,6 +164,12 @@ where
Ok(())
}
+/// Should a handle_* function be called on this element?
+fn should_handle(state: &State, config: &Config) -> bool {
+ let style = config.get_style(state);
+ !(style.is_raw && style.decoration_style == DecorationStyle::NoDecoration)
+}
+
/// Try to detect what is producing the input for delta.
///
/// Currently can detect: