| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().; |
| 2 | |
| 3 | use lazy_staticrust-analyzer cargo lazy_static 1.4.0 crate/::lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!; |
| 4 | |
| 5 | use craterust-analyzer cargo git-delta 0.19.2 crate/::clirust-analyzer cargo git-delta 0.19.2 cli/; |
| 6 | use craterust-analyzer cargo git-delta 0.19.2 crate/::configrust-analyzer cargo git-delta 0.19.2 config/::{delta_unreachablerust-analyzer cargo git-delta 0.19.2 config/delta_unreachable()., Configrust-analyzer cargo git-delta 0.19.2 config/Config#}; |
| 7 | use craterust-analyzer cargo git-delta 0.19.2 crate/::deltarust-analyzer cargo git-delta 0.19.2 delta/::{DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#, MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#, StateMachinerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#}; |
| 8 | use craterust-analyzer cargo git-delta 0.19.2 crate/::paintrust-analyzer cargo git-delta 0.19.2 paint/::{preparerust-analyzer cargo git-delta 0.19.2 paint/prepare()., prepare_raw_linerust-analyzer cargo git-delta 0.19.2 paint/prepare_raw_line().}; |
| 9 | use craterust-analyzer cargo git-delta 0.19.2 crate/::stylerust-analyzer cargo git-delta 0.19.2 style/; |
| 10 | use craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::processrust-analyzer cargo git-delta 0.19.2 utils/process/::{selfrust-analyzer cargo git-delta 0.19.2 utils/process/, CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#}; |
| 11 | use craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::tabsrust-analyzer cargo git-delta 0.19.2 utils/tabs/; |
| 12 | |
| 13 | // HACK: WordDiff should probably be a distinct top-level line state |
| 14 | pub fn is_word_diffrust-analyzer cargo git-delta 0.19.2 handlers/hunk/is_word_diff().() -> bool { |
| 15 | #[cfg(not(test))] |
| 16 | { |
| 17 | *CACHED_IS_WORD_DIFFrust-analyzer cargo git-delta 0.19.2 handlers/hunk/CACHED_IS_WORD_DIFF# |
| 18 | } |
| 19 | #[cfg(test)] |
| 20 | { |
| 21 | compute_is_word_diffrust-analyzer cargo git-delta 0.19.2 handlers/hunk/compute_is_word_diff().() |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! { |
| 26 | static ref CACHED_IS_WORD_DIFFrust-analyzer cargo git-delta 0.19.2 handlers/hunk/CACHED_IS_WORD_DIFF#: bool = compute_is_word_diffrust-analyzer cargo git-delta 0.19.2 handlers/hunk/compute_is_word_diff().(); |
| 27 | } |
| 28 | |
| 29 | fn compute_is_word_diffrust-analyzer cargo git-delta 0.19.2 handlers/hunk/compute_is_word_diff().() -> bool { |
| 30 | match &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().processrust-analyzer cargo git-delta 0.19.2 utils/process/::calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/calling_process().() { |
| 31 | CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitDiffrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitDiff#(cmd_line) |
| 32 | | CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitShowrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitShow#(cmd_line, _) |
| 33 | | CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitLogrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitLog#(cmd_line) |
| 34 | | CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitReflogrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitReflog#(cmd_line) => { |
| 35 | cmd_line.long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("--word-diff") |
| 36 | || cmd_line.long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("--word-diff-regex") |
| 37 | || cmd_line.long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("--color-words") |
| 38 | } |
| 39 | _ => false, |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | impl StateMachinerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#<'_> { |
| 44 | #[inline] |
| 45 | fn test_hunk_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk/impl#[`StateMachine<'_>`]test_hunk_line().(&self) -> bool { |
| 46 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 47 | self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state., |
| 48 | Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#HunkHeader#(_, _, _, _) |
| 49 | | Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(_, _) |
| 50 | | Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(_, _) |
| 51 | | Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(_, _) |
| 52 | ) |
| 53 | } |
| 54 | |
| 55 | /// Handle a hunk line, i.e. a minus line, a plus line, or an unchanged line. |
| 56 | // In the case of a minus or plus line, we store the line in a |
| 57 | // buffer. When we exit the changed region we process the collected |
| 58 | // minus and plus lines jointly, in order to paint detailed |
| 59 | // highlighting according to inferred edit operations. In the case of |
| 60 | // an unchanged line, we paint it immediately. |
| 61 | pub fn handle_hunk_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk/impl#[`StateMachine<'_>`]handle_hunk_line().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool> { |
| 62 | use DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#::*; |
| 63 | use Staterust-analyzer cargo git-delta 0.19.2 delta/State#::*; |
| 64 | |
| 65 | // A true hunk line should start with one of: '+', '-', ' '. However, handle_hunk_line |
| 66 | // handles all lines until the state transitions away from the hunk states. |
| 67 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.test_hunk_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk/impl#[`StateMachine<'_>`]test_hunk_line().() { |
| 68 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 69 | } |
| 70 | // Don't let the line buffers become arbitrarily large -- if we |
| 71 | // were to allow that, then for a large deleted/added file we |
| 72 | // would process the entire file before painting anything. |
| 73 | if self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..minus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#minus_lines..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..line_buffer_sizerust-analyzer cargo git-delta 0.19.2 config/Config#line_buffer_size. |
| 74 | || self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..plus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#plus_lines..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..line_buffer_sizerust-analyzer cargo git-delta 0.19.2 config/Config#line_buffer_size. |
| 75 | { |
| 76 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..paint_buffered_minus_and_plus_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_buffered_minus_and_plus_lines().(); |
| 77 | } |
| 78 | if let Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#HunkHeader#(_, parsed_hunk_header, line, raw_line) = &self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state..clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().() { |
| 79 | self.emit_hunk_header_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk_header/impl#[`StateMachine<'_>`]emit_hunk_header_line().(parsed_hunk_header, line, raw_line)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 80 | } |
| 81 | self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state. = match new_line_staterust-analyzer cargo git-delta 0.19.2 handlers/hunk/new_line_state().(&self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line., &self.raw_linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#raw_line., &self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state., self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.) { |
| 82 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(diff_type, raw_line)) => { |
| 83 | if let HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(_, _) = self.staterust-analyzer cargo git-delta 0.19.2 delta/StateMachine#state. { |
| 84 | // We have just entered a new subhunk; process the previous one |
| 85 | // and flush the line buffers. |
| 86 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..paint_buffered_minus_and_plus_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_buffered_minus_and_plus_lines().(); |
| 87 | } |
| 88 | let n_parents = diff_type.n_parentsrust-analyzer cargo git-delta 0.19.2 delta/impl#[DiffType]n_parents().(); |
| 89 | let line = preparerust-analyzer cargo git-delta 0.19.2 paint/prepare().(&self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line., n_parents, self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.); |
| 90 | let state = HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(diff_type, raw_line); |
| 91 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..minus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#minus_lines..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((line, state.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().())); |
| 92 | self.minus_line_counterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#minus_line_counter..count_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk_header/impl#[AmbiguousDiffMinusCounter]count_line().(); |
| 93 | state |
| 94 | } |
| 95 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(diff_type, raw_line)) => { |
| 96 | let n_parents = diff_type.n_parentsrust-analyzer cargo git-delta 0.19.2 delta/impl#[DiffType]n_parents().(); |
| 97 | let line = preparerust-analyzer cargo git-delta 0.19.2 paint/prepare().(&self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line., n_parents, self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.); |
| 98 | let state = HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(diff_type, raw_line); |
| 99 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..plus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#plus_lines..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((line, state.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().())); |
| 100 | state |
| 101 | } |
| 102 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(diff_type, raw_line)) => { |
| 103 | // We are in a zero (unchanged) line, therefore we have just exited a subhunk (a |
| 104 | // sequence of consecutive minus (removed) and/or plus (added) lines). Process that |
| 105 | // subhunk and flush the line buffers. |
| 106 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..paint_buffered_minus_and_plus_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_buffered_minus_and_plus_lines().(); |
| 107 | let n_parents = if is_word_diffrust-analyzer cargo git-delta 0.19.2 handlers/hunk/is_word_diff().() { |
| 108 | 0 |
| 109 | } else { |
| 110 | diff_type.n_parentsrust-analyzer cargo git-delta 0.19.2 delta/impl#[DiffType]n_parents().() |
| 111 | }; |
| 112 | let line = preparerust-analyzer cargo git-delta 0.19.2 paint/prepare().(&self.linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#line., n_parents, self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config.); |
| 113 | let state = Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(diff_type, raw_line); |
| 114 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..paint_zero_linerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_zero_line().(&line, state.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().()); |
| 115 | self.minus_line_counterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#minus_line_counter..count_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk_header/impl#[AmbiguousDiffMinusCounter]count_line().(); |
| 116 | state |
| 117 | } |
| 118 | _ => { |
| 119 | // The first character here could be e.g. '\' from '\ No newline at end of file'. This |
| 120 | // is not a hunk line, but the parser does not have a more accurate state corresponding |
| 121 | // to this. |
| 122 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..paint_buffered_minus_and_plus_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_buffered_minus_and_plus_lines().(); |
| 123 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter. |
| 124 | .output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer. |
| 125 | .push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&tabsrust-analyzer cargo git-delta 0.19.2 utils/tabs/::expandrust-analyzer cargo git-delta 0.19.2 utils/tabs/expand().(&self.raw_linerust-analyzer cargo git-delta 0.19.2 delta/StateMachine#raw_line., &self.configrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#config..tab_cfgrust-analyzer cargo git-delta 0.19.2 config/Config#tab_cfg.)); |
| 126 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n'); |
| 127 | Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 128 | } |
| 129 | }; |
| 130 | self.painterrust-analyzer cargo git-delta 0.19.2 delta/StateMachine#painter..emitrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]emit().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 131 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // Return Some(prepared_raw_line) if delta should emit this line raw. |
| 136 | fn maybe_raw_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk/maybe_raw_line().( |
| 137 | raw_line: &str, |
| 138 | state_style_is_raw: bool, |
| 139 | n_parents: usize, |
| 140 | non_raw_styles: &[stylerust-analyzer cargo git-delta 0.19.2 style/::Stylerust-analyzer cargo git-delta 0.19.2 style/Style#], |
| 141 | config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 142 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 143 | let emit_raw_line = is_word_diffrust-analyzer cargo git-delta 0.19.2 handlers/hunk/is_word_diff().() |
| 144 | || config.inspect_raw_linesrust-analyzer cargo git-delta 0.19.2 config/Config#inspect_raw_lines. rust-analyzer cargo git-delta 0.19.2 cli/impl#[InspectRawLines][`PartialEq<Self>`]eq().==rust-analyzer cargo git-delta 0.19.2 cli/impl#[InspectRawLines][`PartialEq<Self>`]eq(). rust-analyzer cargo git-delta 0.19.2 cli/impl#[InspectRawLines][`PartialEq<Self>`]eq().clirust-analyzer cargo git-delta 0.19.2 cli/::InspectRawLinesrust-analyzer cargo git-delta 0.19.2 cli/InspectRawLines#::Truerust-analyzer cargo git-delta 0.19.2 cli/InspectRawLines#True# |
| 145 | && stylerust-analyzer cargo git-delta 0.19.2 style/::line_has_style_other_thanrust-analyzer cargo git-delta 0.19.2 style/line_has_style_other_than().(raw_line, non_raw_styles) |
| 146 | || state_style_is_raw; |
| 147 | if emit_raw_line { |
| 148 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prepare_raw_linerust-analyzer cargo git-delta 0.19.2 paint/prepare_raw_line().(raw_line, n_parents, config)) |
| 149 | } else { |
| 150 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | // Return the new state corresponding to `new_line`, given the previous state. A return value of |
| 155 | // None means that `new_line` is not recognized as a hunk line. |
| 156 | fn new_line_staterust-analyzer cargo git-delta 0.19.2 handlers/hunk/new_line_state().( |
| 157 | new_line: &str, |
| 158 | new_raw_line: &str, |
| 159 | prev_state: &Staterust-analyzer cargo git-delta 0.19.2 delta/State#, |
| 160 | config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 161 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Staterust-analyzer cargo git-delta 0.19.2 delta/State#> { |
| 162 | use DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#::*; |
| 163 | use MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#::*; |
| 164 | use Staterust-analyzer cargo git-delta 0.19.2 delta/State#::*; |
| 165 | |
| 166 | if is_word_diffrust-analyzer cargo git-delta 0.19.2 handlers/hunk/is_word_diff().() { |
| 167 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#( |
| 168 | Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, |
| 169 | maybe_raw_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk/maybe_raw_line().(new_raw_line, config.zero_stylerust-analyzer cargo git-delta 0.19.2 config/Config#zero_style..is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw., 0, &[], config), |
| 170 | )); |
| 171 | } |
| 172 | |
| 173 | // 1. Given the previous line state, compute the new line diff type. These are basically the |
| 174 | // same, except that a string prefix is converted into an integer number of parents (prefix |
| 175 | // length). |
| 176 | let diff_type = match prev_state { |
| 177 | HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, _) |
| 178 | | HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, _) |
| 179 | | HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, _) |
| 180 | | HunkHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#HunkHeader#(Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, _, _, _) => Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, |
| 181 | HunkHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#HunkHeader#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Numberrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Number#(n), InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), _, _, _) => { |
| 182 | Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Numberrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Number#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().n), InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#) |
| 183 | } |
| 184 | // The prefixes are specific to the previous line, but the number of merge parents remains |
| 185 | // equal to the prefix length. |
| 186 | HunkHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#HunkHeader#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), _, _, _) => { |
| 187 | Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Numberrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Number#(prefix.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().()), InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#) |
| 188 | } |
| 189 | HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), in_merge_conflict), _) |
| 190 | | HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), in_merge_conflict), _) |
| 191 | | HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), in_merge_conflict), _) => { |
| 192 | Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Numberrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Number#(prefix.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().()), in_merge_conflict.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[InMergeConflict][Clone]clone().()) |
| 193 | } |
| 194 | HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Numberrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Number#(n), in_merge_conflict), _) |
| 195 | | HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Numberrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Number#(n), in_merge_conflict), _) |
| 196 | | HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Numberrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Number#(n), in_merge_conflict), _) => { |
| 197 | Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Numberrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Number#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().n), in_merge_conflict.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[InMergeConflict][Clone]clone().()) |
| 198 | } |
| 199 | _ => delta_unreachablerust-analyzer cargo git-delta 0.19.2 config/delta_unreachable().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 200 | "Unexpected state in new_line_state: {prev_state:?}", |
| 201 | )), |
| 202 | }; |
| 203 | |
| 204 | // 2. Given the new diff state, and the new line, compute the new prefix. |
| 205 | let (prefix_char, prefix, in_merge_conflict) = match diff_type.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[DiffType][Clone]clone().() { |
| 206 | Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified# => (new_line.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 207 | Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Numberrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Number#(n_parents), in_merge_conflict) => { |
| 208 | let prefix = &new_line[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(n_parents, new_line.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().())]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 209 | let prefix_char = match prefix.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().&'-' || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().&'+') { |
| 210 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c), |
| 211 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => match prefix.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().&' ') { |
| 212 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(' '), |
| 213 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 214 | }, |
| 215 | }; |
| 216 | ( |
| 217 | prefix_char, |
| 218 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prefix.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 219 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(in_merge_conflict), |
| 220 | ) |
| 221 | } |
| 222 | _ => delta_unreachablerust-analyzer cargo git-delta 0.19.2 config/delta_unreachable().(""), |
| 223 | }; |
| 224 | |
| 225 | let maybe_minus_raw_line = || { |
| 226 | maybe_raw_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk/maybe_raw_line().( |
| 227 | new_raw_line, |
| 228 | config.minus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_style..is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw., |
| 229 | diff_type.n_parentsrust-analyzer cargo git-delta 0.19.2 delta/impl#[DiffType]n_parents().(), |
| 230 | &[*rust-analyzer cargo git-delta 0.19.2 style/impl#[GIT_DEFAULT_MINUS_STYLE][Deref]deref().stylerust-analyzer cargo git-delta 0.19.2 style/::GIT_DEFAULT_MINUS_STYLErust-analyzer cargo git-delta 0.19.2 style/GIT_DEFAULT_MINUS_STYLE., config.git_minus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#git_minus_style.], |
| 231 | config, |
| 232 | ) |
| 233 | }; |
| 234 | let maybe_zero_raw_line = || { |
| 235 | maybe_raw_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk/maybe_raw_line().( |
| 236 | new_raw_line, |
| 237 | config.zero_stylerust-analyzer cargo git-delta 0.19.2 config/Config#zero_style..is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw., |
| 238 | diff_type.n_parentsrust-analyzer cargo git-delta 0.19.2 delta/impl#[DiffType]n_parents().(), |
| 239 | &[], |
| 240 | config, |
| 241 | ) |
| 242 | }; |
| 243 | let maybe_plus_raw_line = || { |
| 244 | maybe_raw_linerust-analyzer cargo git-delta 0.19.2 handlers/hunk/maybe_raw_line().( |
| 245 | new_raw_line, |
| 246 | config.plus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_style..is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw., |
| 247 | diff_type.n_parentsrust-analyzer cargo git-delta 0.19.2 delta/impl#[DiffType]n_parents().(), |
| 248 | &[*rust-analyzer cargo git-delta 0.19.2 style/impl#[GIT_DEFAULT_PLUS_STYLE][Deref]deref().stylerust-analyzer cargo git-delta 0.19.2 style/::GIT_DEFAULT_PLUS_STYLErust-analyzer cargo git-delta 0.19.2 style/GIT_DEFAULT_PLUS_STYLE., config.git_plus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#git_plus_style.], |
| 249 | config, |
| 250 | ) |
| 251 | }; |
| 252 | |
| 253 | // 3. Given the new prefix, compute the full new line state...except without its raw_line, which |
| 254 | // is added later. TODO: that is not a sensible design. |
| 255 | match (prefix_char, prefix, in_merge_conflict) { |
| 256 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('-'), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, maybe_minus_raw_line())), |
| 257 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(' '), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, maybe_zero_raw_line())), |
| 258 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('+'), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(Unifiedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Unified#, maybe_plus_raw_line())), |
| 259 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('-'), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prefix), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(in_merge_conflict)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#( |
| 260 | Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), in_merge_conflict), |
| 261 | maybe_minus_raw_line(), |
| 262 | )), |
| 263 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(' '), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prefix), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(in_merge_conflict)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#( |
| 264 | Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), in_merge_conflict), |
| 265 | maybe_zero_raw_line(), |
| 266 | )), |
| 267 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('+'), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prefix), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(in_merge_conflict)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#( |
| 268 | Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), in_merge_conflict), |
| 269 | maybe_plus_raw_line(), |
| 270 | )), |
| 271 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | #[cfg(test)] |
| 276 | mod testsrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/ { |
| 277 | use craterust-analyzer cargo git-delta 0.19.2 crate/::testsrust-analyzer cargo git-delta 0.19.2 tests/::integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#; |
| 278 | |
| 279 | mod word_diffrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/ { |
| 280 | use superrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/::*; |
| 281 | |
| 282 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 283 | fn test_word_diffrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/test_word_diff().() { |
| 284 | DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_args().(&[]) |
| 285 | .with_calling_processrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_calling_process().("git diff --word-diff") |
| 286 | .explain_ansirust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]explain_ansi().() |
| 287 | .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(GIT_DIFF_WORD_DIFFrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/GIT_DIFF_WORD_DIFF.) |
| 288 | .expect_after_skiprust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_skip().( |
| 289 | 11, |
| 290 | " |
| 291 | #indent_mark |
| 292 | (blue)───(blue)┐(normal) |
| 293 | (blue)1(normal): (blue)│(normal) |
| 294 | (blue)───(blue)┘(normal) |
| 295 | (red)[-aaa-](green){+bbb+}(normal) |
| 296 | ", |
| 297 | ); |
| 298 | } |
| 299 | |
| 300 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 301 | fn test_color_wordsrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/test_color_words().() { |
| 302 | DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_args().(&[]) |
| 303 | .with_calling_processrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_calling_process().("git diff --color-words") |
| 304 | .explain_ansirust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]explain_ansi().() |
| 305 | .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(GIT_DIFF_COLOR_WORDSrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/GIT_DIFF_COLOR_WORDS.) |
| 306 | .expect_after_skiprust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_skip().( |
| 307 | 11, |
| 308 | " |
| 309 | #indent_mark |
| 310 | (blue)───(blue)┐(normal) |
| 311 | (blue)1(normal): (blue)│(normal) |
| 312 | (blue)───(blue)┘(normal) |
| 313 | (red)aaa(green)bbb(normal) |
| 314 | ", |
| 315 | ); |
| 316 | } |
| 317 | |
| 318 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 319 | #[ignore] // FIXME |
| 320 | fn test_color_words_map_stylesrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/test_color_words_map_styles().() { |
| 321 | DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_args().(&[ |
| 322 | "--map-styles", |
| 323 | "red => bold yellow #dddddd, green => bold blue #dddddd", |
| 324 | ]) |
| 325 | .with_calling_processrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_calling_process().("git diff --color-words") |
| 326 | .explain_ansirust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]explain_ansi().() |
| 327 | .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(GIT_DIFF_COLOR_WORDSrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/GIT_DIFF_COLOR_WORDS.) |
| 328 | .inspectrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]inspect().() |
| 329 | .expect_after_skiprust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_skip().( |
| 330 | 11, |
| 331 | r##" |
| 332 | #indent_mark |
| 333 | (blue)───(blue)┐(normal) |
| 334 | (blue)1(normal): (blue)│(normal) |
| 335 | (blue)───(blue)┘(normal) |
| 336 | (bold yellow "#dddddd")aaa(bold blue "#dddddd")bbb(normal) |
| 337 | "##, |
| 338 | ); |
| 339 | } |
| 340 | |
| 341 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 342 | fn test_hunk_line_style_rawrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/test_hunk_line_style_raw().() { |
| 343 | DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_args().(&["--minus-style", "raw", "--plus-style", "raw"]) |
| 344 | .explain_ansirust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]explain_ansi().() |
| 345 | .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(GIT_DIFF_WITH_COLORrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/GIT_DIFF_WITH_COLOR.) |
| 346 | .expect_after_skiprust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_skip().( |
| 347 | 14, |
| 348 | " |
| 349 | (red)aaa(normal) |
| 350 | (green)bbb(normal) |
| 351 | ", |
| 352 | ); |
| 353 | } |
| 354 | |
| 355 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 356 | fn test_hunk_line_style_raw_map_stylesrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/test_hunk_line_style_raw_map_styles().() { |
| 357 | DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_args().(&[ |
| 358 | "--minus-style", |
| 359 | "raw", |
| 360 | "--plus-style", |
| 361 | "raw", |
| 362 | "--map-styles", |
| 363 | "red => bold blue, green => dim yellow", |
| 364 | ]) |
| 365 | .explain_ansirust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]explain_ansi().() |
| 366 | .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(GIT_DIFF_WITH_COLORrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/GIT_DIFF_WITH_COLOR.) |
| 367 | .expect_after_skiprust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_skip().( |
| 368 | 14, |
| 369 | " |
| 370 | (bold blue)aaa(normal) |
| 371 | (dim yellow)bbb(normal) |
| 372 | ", |
| 373 | ); |
| 374 | } |
| 375 | |
| 376 | const GIT_DIFF_WITH_COLORrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/GIT_DIFF_WITH_COLOR.: &str = r#"\ |
| 377 | [33mcommit 3ef7fba7258fe473f1d8befff367bb793c786107[m |
| 378 | Author: Dan Davison <[email protected]> |
| 379 | Date: Mon Dec 13 22:54:43 2021 -0500 |
| 380 | |
| 381 | 753 Test file |
| 382 | |
| 383 | [1mdiff --git a/file b/file[m |
| 384 | [1mindex 72943a1..f761ec1 100644[m |
| 385 | [1m--- a/file[m |
| 386 | [1m+++ b/file[m |
| 387 | [31m@@ -1 +1 @@[m |
| 388 | [31m-aaa[m |
| 389 | [32m+[m[32mbbb[m |
| 390 | "#; |
| 391 | |
| 392 | const GIT_DIFF_COLOR_WORDSrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/GIT_DIFF_COLOR_WORDS.: &str = r#"\ |
| 393 | [33mcommit 6feea4949c20583aaf16eee84f38d34d6a7f1741[m |
| 394 | Author: Dan Davison <[email protected]> |
| 395 | Date: Sat Dec 11 17:08:56 2021 -0500 |
| 396 | |
| 397 | file v2 |
| 398 | |
| 399 | [1mdiff --git a/file b/file[m |
| 400 | [1mindex c005da6..962086f 100644[m |
| 401 | [1m--- a/file[m |
| 402 | [1m+++ b/file[m |
| 403 | [31m@@ -1 +1 @@[m |
| 404 | [31maaa[m[32mbbb[m |
| 405 | "#; |
| 406 | |
| 407 | const GIT_DIFF_WORD_DIFFrust-analyzer cargo git-delta 0.19.2 handlers/hunk/tests/word_diff/GIT_DIFF_WORD_DIFF.: &str = r#"\ |
| 408 | [33mcommit 6feea4949c20583aaf16eee84f38d34d6a7f1741[m |
| 409 | Author: Dan Davison <[email protected]> |
| 410 | Date: Sat Dec 11 17:08:56 2021 -0500 |
| 411 | |
| 412 | file v2 |
| 413 | |
| 414 | [1mdiff --git a/file b/file[m |
| 415 | [1mindex c005da6..962086f 100644[m |
| 416 | [1m--- a/file[m |
| 417 | [1m+++ b/file[m |
| 418 | [31m@@ -1 +1 @@[m |
| 419 | [31m[-aaa-][m[32m{+bbb+}[m |
| 420 | "#; |
| 421 | } |
| 422 | } |