diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-11-29 12:32:56 -0500 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-11-29 20:22:25 -0500 |
commit | 6271fca60fce486eba5d4dcd1c5add1cc47b0836 (patch) | |
tree | ae7e3548c1fd9c5cf74b4d40454c4b744c3e0eea | |
parent | b121d60c6eba06b6cd7de9add9ed938519853120 (diff) |
Refactor: `if let` instead of `match`
-rw-r--r-- | src/paint.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/paint.rs b/src/paint.rs index d47c7689..5821ee92 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -701,13 +701,14 @@ impl<'p> Painter<'p> { .zip_eq(lines_style_sections) .zip_eq(lines_have_homolog) { - match state { - State::HunkMinus(Some(raw_line)) | State::HunkPlus(Some(raw_line)) => { - *style_sections = parse_style_sections(raw_line, config); - continue; - } - _ => {} - }; + if let State::HunkMinus(Some(raw_line)) | State::HunkPlus(Some(raw_line)) = state { + // raw_line is captured in handle_hunk_line under certain conditions. If we have + // done so, then overwrite the style sections with styles parsed directly from the + // raw line. Currently the only reason this is done is to handle a diff.colorMoved + // line. + *style_sections = parse_style_sections(raw_line, config); + continue; + } let line_has_emph_and_non_emph_sections = style_sections_contain_more_than_one_style(style_sections); let should_update_non_emph_styles = non_emph_style.is_some() && *line_has_homolog; |