Debian Codegraph @

src/wrapping.rs

raw symbols SCIP
1 use syntectrust-analyzer cargo syntect 5.3.0 crate/::highlightingrust-analyzer cargo syntect 5.3.0 highlighting/::Stylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style# as SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#;
2 use unicode_segmentationrust-analyzer cargo unicode-segmentation 1.12.0 crate/::UnicodeSegmentationrust-analyzer cargo unicode-segmentation 1.12.0 UnicodeSegmentation#;
3 use unicode_widthrust-analyzer cargo unicode-width 0.1.14 crate/::UnicodeWidthStrrust-analyzer cargo unicode-width 0.1.14 UnicodeWidthStr#;
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/::INLINE_SYMBOL_WIDTH_1rust-analyzer cargo git-delta 0.19.2 config/INLINE_SYMBOL_WIDTH_1.;
7 use craterust-analyzer cargo git-delta 0.19.2 crate/::fatalrust-analyzer cargo git-delta 0.19.2 fatal().;
8
9 use craterust-analyzer cargo git-delta 0.19.2 crate/::configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#;
10 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#;
11 use craterust-analyzer cargo git-delta 0.19.2 crate/::deltarust-analyzer cargo git-delta 0.19.2 delta/::Staterust-analyzer cargo git-delta 0.19.2 delta/State#;
12 use craterust-analyzer cargo git-delta 0.19.2 crate/::featuresrust-analyzer cargo git-delta 0.19.2 features/::line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::{selfrust-analyzer cargo git-delta 0.19.2 features/line_numbers/, SideBySideLineWidthrust-analyzer cargo git-delta 0.19.2 features/line_numbers/SideBySideLineWidth#};
13 use craterust-analyzer cargo git-delta 0.19.2 crate/::featuresrust-analyzer cargo git-delta 0.19.2 features/::side_by_siderust-analyzer cargo git-delta 0.19.2 features/side_by_side/::{available_line_widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/available_line_width()., line_is_too_longrust-analyzer cargo git-delta 0.19.2 features/side_by_side/line_is_too_long()., Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#, Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#};
14 use craterust-analyzer cargo git-delta 0.19.2 crate/::minusplusrust-analyzer cargo git-delta 0.19.2 minusplus/::*;
15 use craterust-analyzer cargo git-delta 0.19.2 crate/::paintrust-analyzer cargo git-delta 0.19.2 paint/::LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#;
16 use craterust-analyzer cargo git-delta 0.19.2 crate/::stylerust-analyzer cargo git-delta 0.19.2 style/::Stylerust-analyzer cargo git-delta 0.19.2 style/Style#;
17 use craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::syntectrust-analyzer cargo git-delta 0.19.2 utils/syntect/::FromDeltaStylerust-analyzer cargo git-delta 0.19.2 utils/syntect/FromDeltaStyle#;
18
19 /// See [`wrap_line`] for documentation.
20 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
21 pub struct WrapConfigrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig# {
22 pub left_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#left_symbol.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
23 pub right_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#right_symbol.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
24 pub right_prefix_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#right_prefix_symbol.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
25 // In fractions of 1000 so that a >100 wide panel can
26 // still be configured down to a single character.
27 pub use_wrap_right_permillerust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#use_wrap_right_permille.: usize,
28 // This value is --wrap-max-lines + 1, and unlimited is 0, see
29 // adapt_wrap_max_lines_argument()
30 pub max_linesrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#max_lines.: usize,
31 pub inline_hint_syntect_stylerust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#inline_hint_syntect_style.: SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#,
32 }
33
34 impl WrapConfigrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig# {
35 pub fn from_optrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[WrapConfig]from_opt().(opt: &clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#, inline_hint_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#) -> Selfrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[WrapConfig] {
36 Selfrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[WrapConfig] {
37 left_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#left_symbol.: ensure_display_width_1rust-analyzer cargo git-delta 0.19.2 wrapping/ensure_display_width_1().("wrap-left-symbol", opt.wrap_left_symbolrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_left_symbol..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()),
38 right_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#right_symbol.: ensure_display_width_1rust-analyzer cargo git-delta 0.19.2 wrapping/ensure_display_width_1().(
39 "wrap-right-symbol",
40 opt.wrap_right_symbolrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_right_symbol..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(),
41 ),
42 right_prefix_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#right_prefix_symbol.: ensure_display_width_1rust-analyzer cargo git-delta 0.19.2 wrapping/ensure_display_width_1().(
43 "wrap-right-prefix-symbol",
44 opt.wrap_right_prefix_symbolrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_right_prefix_symbol..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(),
45 ),
46 use_wrap_right_permillerust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#use_wrap_right_permille.: {
47 let arg = &opt.wrap_right_percentrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_right_percent.;
48 let percent = remove_percent_suffixrust-analyzer cargo git-delta 0.19.2 wrapping/remove_percent_suffix().(arg)
49 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<f64>()
50 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|err| {
51 fatalrust-analyzer cargo git-delta 0.19.2 fatal().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
52 "Could not parse wrap-right-percent argument {}: {}.",
53 &arg, err
54 ))
55 });
56 if percent.is_finiterust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_finite().() && percent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().0.0 && percent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().100.0 {
57 (percent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().10.0).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as usize
58 } else {
59 fatalrust-analyzer cargo git-delta 0.19.2 fatal().("Invalid value for wrap-right-percent, not between 0 and 100.")
60 }
61 },
62 max_linesrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#max_lines.: adapt_wrap_max_lines_argumentrust-analyzer cargo git-delta 0.19.2 wrapping/adapt_wrap_max_lines_argument().(opt.wrap_max_linesrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_max_lines..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()),
63 inline_hint_syntect_stylerust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#inline_hint_syntect_style.: SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#::from_delta_stylerust-analyzer cargo git-delta 0.19.2 utils/syntect/impl#[Style][FromDeltaStyle]from_delta_style().(inline_hint_style),
64 }
65 }
66
67 // Compute value of `max_line_length` field in the main `Config` struct.
68 pub fn config_max_line_lengthrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[WrapConfig]config_max_line_length().(
69 &self,
70 max_line_length: usize,
71 available_terminal_width: usize,
72 ) -> usize {
73 match self.max_linesrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#max_lines. {
74 1 => max_line_length,
75 // Ensure there is enough text to wrap, either don't truncate the input at all (0)
76 // or ensure there is enough for the requested number of lines.
77 // The input can contain ANSI sequences, so round up a bit. This is enough for
78 // normal `git diff`, but might not be with ANSI heavy input.
79 0 => 0,
80 wrap_max_lines => {
81 let single_pane_width = available_terminal_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2;
82 let add_25_percent_or_term_width =
83 |x| x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().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/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().((x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().250) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().1000, single_pane_width);
84 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/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(
85 max_line_length,
86 add_25_percent_or_term_width(single_pane_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().wrap_max_lines),
87 )
88 }
89 }
90 }
91 }
92
93 fn remove_percent_suffixrust-analyzer cargo git-delta 0.19.2 wrapping/remove_percent_suffix().(arg: &str) -> &str {
94 match &arg.strip_suffixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_suffix().('%') {
95 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) => s,
96 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => arg,
97 }
98 }
99
100 fn ensure_display_width_1rust-analyzer cargo git-delta 0.19.2 wrapping/ensure_display_width_1().(what: &str, arg: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
101 match arg.grapheme_indicesrust-analyzer cargo unicode-segmentation 1.12.0 impl#[str][UnicodeSegmentation]grapheme_indices().(true).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().() {
102 INLINE_SYMBOL_WIDTH_1rust-analyzer cargo git-delta 0.19.2 config/INLINE_SYMBOL_WIDTH_1. => arg,
103 width => fatalrust-analyzer cargo git-delta 0.19.2 fatal().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
104 "Invalid value for {what}, display width of \"{arg}\" must be {INLINE_SYMBOL_WIDTH_1} but is {width}",
105 )),
106 }
107 }
108
109 fn adapt_wrap_max_lines_argumentrust-analyzer cargo git-delta 0.19.2 wrapping/adapt_wrap_max_lines_argument().(arg: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> usize {
110 if arg rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."∞" || arg rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."unlimited" || arg.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("inf") {
111 0
112 } else {
113 arg.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<usize>()
114 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|err| fatalrust-analyzer cargo git-delta 0.19.2 fatal().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Invalid wrap-max-lines argument: {err}")))
115 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1
116 }
117 }
118
119 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
120 enum Stoprust-analyzer cargo git-delta 0.19.2 wrapping/Stop# {
121 StackEmptyrust-analyzer cargo git-delta 0.19.2 wrapping/Stop#StackEmpty#,
122 LineLimitrust-analyzer cargo git-delta 0.19.2 wrapping/Stop#LineLimit#,
123 }
124
125 /// Wrap the given `line` if it is longer than `line_width`. Wrap to at most
126 /// [Config::WrapConfig::max_lines](WrapConfig::max_lines) lines,
127 /// then truncate again - but never truncate if it is `0`. Place
128 /// [left_symbol](WrapConfig::left_symbol) at the end of wrapped lines.
129 /// If wrapping results in only *one* extra line and if the width of the wrapped
130 /// line is less than [use_wrap_right_permille](WrapConfig::use_wrap_right_permille)
131 /// then right-align the second line and use the symbols
132 /// [right_symbol](WrapConfig::right_symbol) and
133 /// on the next line [right_prefix_symbol](WrapConfig::right_prefix_symbol).
134 /// The inserted characters will follow the
135 /// [inline_hint_syntect_style](WrapConfig::inline_hint_syntect_style).
136 pub fn wrap_linerust-analyzer cargo git-delta 0.19.2 wrapping/wrap_line().<'a, I, S>(
137 config: &'a Configrust-analyzer cargo git-delta 0.19.2 config/Config#,
138 line: I,
139 line_width: usize,
140 fill_style: &S,
141 inline_hint_style: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<S>,
142 ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, S>>
143 where
144 I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (S, &'a str)> + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
145 <I as IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#>::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#: DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#,
146 S: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
147 {
148 let mut result = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
149
150 let wrap_config = &config.wrap_configrust-analyzer cargo git-delta 0.19.2 config/Config#wrap_config.;
151
152 // The current line being assembled from the input to fit exactly into the given width.
153 // A somewhat leaky abstraction as the fields are also accessed directly.
154 struct CurrLinerust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#<'a, S: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#> {
155 line_segmentsrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#line_segments.: LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, S>,
156 lenrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#len.: usize,
157 }
158 impl<'a, S: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#> CurrLinerust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#<'a, S> {
159 fn resetrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]reset().() -> Selfrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`] {
160 CurrLinerust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine# {
161 line_segmentsrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#line_segments.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(),
162 lenrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#len.: 0,
163 }
164 }
165 fn push_and_set_lenrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]push_and_set_len().(&mut self, text: (S, &'a str), len: usize) {
166 self.line_segmentsrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#line_segments..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(text);
167 self.lenrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#len. = len;
168 }
169 fn has_textrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]has_text().(&self) -> bool {
170 self.lenrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#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().0
171 }
172 fn text_lenrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]text_len().(&self) -> usize {
173 self.lenrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#len.
174 }
175 }
176
177 let mut curr_line = CurrLinerust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#::resetrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]reset().();
178
179 // Determine the background (diff) and color (syntax) of an inserted symbol.
180 let symbol_style = match inline_hint_style {
181 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(style) => *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().style,
182 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().fill_style,
183 };
184
185 let mut stack = line.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
186
187 // If only the wrap symbol and no extra text fits, then wrapping is not possible.
188 let max_lines = if line_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().INLINE_SYMBOL_WIDTH_1rust-analyzer cargo git-delta 0.19.2 config/INLINE_SYMBOL_WIDTH_1. {
189 1
190 } else {
191 wrap_config.max_linesrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#max_lines.
192 };
193
194 let line_limit_reached = |result: &Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>| max_lines 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().0 && result.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 ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().max_lines;
195
196 let stop = loop {
197 if stack.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
198 break Stoprust-analyzer cargo git-delta 0.19.2 wrapping/Stop#::StackEmptyrust-analyzer cargo git-delta 0.19.2 wrapping/Stop#StackEmpty#;
199 } else if line_limit_reached(&result) {
200 break Stoprust-analyzer cargo git-delta 0.19.2 wrapping/Stop#::LineLimitrust-analyzer cargo git-delta 0.19.2 wrapping/Stop#LineLimit#;
201 }
202
203 let (style, text, graphemes) = stack
204 .poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().()
205 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(style, text)| {
206 (
207 style,
208 text,
209 text.graphemesrust-analyzer cargo unicode-segmentation 1.12.0 impl#[str][UnicodeSegmentation]graphemes().(true)
210 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|item| (item.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().(), item.widthrust-analyzer cargo unicode-width 0.1.14 impl#[str][UnicodeWidthStr]width().()))
211 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(),
212 )
213 })
214 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
215
216 let graphemes_width: usize = graphemes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(_, w)| w).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().();
217 let new_len = curr_line.lenrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#len. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().graphemes_width;
218
219 #[allow(clippy::comparison_chain)]
220 let must_split = if new_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().line_width {
221 curr_line.push_and_set_lenrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]push_and_set_len().((style, text), new_len);
222 false
223 } else if new_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().line_width {
224 match stack.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().() {
225 // Perfect fit, no need to make space for a `wrap_symbol`.
226 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
227 curr_line.push_and_set_lenrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]push_and_set_len().((style, text), new_len);
228 false
229 }
230 #[allow(clippy::identity_op)]
231 // A single '\n' left on the stack can be pushed onto the current line.
232 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((next_style, nl)) if stack.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][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 && *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().nl 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()."\n" => {
233 curr_line.push_and_set_lenrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]push_and_set_len().((style, text), new_len);
234 // Do not count the '\n': + 0
235 curr_line.push_and_set_lenrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]push_and_set_len().((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().next_style, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().nl), new_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().0);
236 stack.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().();
237 false
238 }
239 _ => true,
240 }
241 } else {
242 true
243 };
244
245 // Text must be split, one part (or just `wrap_symbol`) is added to the
246 // current line, the other is pushed onto the stack.
247 if must_split {
248 let mut width_left = graphemes_width
249 .saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(new_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().line_width)
250 .saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(wrap_config.left_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#left_symbol..widthrust-analyzer cargo unicode-width 0.1.14 impl#[str][UnicodeWidthStr]width().());
251
252 // The length does not matter anymore and `curr_line` will be reset
253 // at the end, so move the line segments out.
254 let mut line_segments = curr_line.line_segmentsrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#line_segments.;
255
256 let next_line = if width_left rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
257 text
258 } else {
259 let mut byte_split_pos = 0;
260 // After loop byte_split_pos may still equal to 0. If width_left
261 // is less than the width of first character, We can't display it.
262 for &(item_len, item_width) in graphemes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
263 if width_left rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().item_width {
264 byte_split_pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().item_len;
265 width_left rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().item_width;
266 } else {
267 break;
268 }
269 }
270
271 let this_line = &text[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#byte_split_pos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
272 line_segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((style, this_line));
273 &text[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().byte_split_pos..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
274 };
275 stack.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((style, next_line));
276
277 line_segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((symbol_style, &wrap_config.left_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#left_symbol.));
278 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(line_segments);
279
280 curr_line = CurrLinerust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#::resetrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]reset().();
281 }
282 };
283
284 // Right-align wrapped line:
285 // Done if wrapping adds exactly one line and this line is less than the given
286 // permille wide. Also change the wrap symbol at the end of the previous (first) line.
287 if result.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][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 && curr_line.has_textrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]has_text().() {
288 let current_permille = (curr_line.text_lenrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]text_len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().1000) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().line_width;
289
290 // pad line will add a wrap_config.right_prefix_symbol
291 let pad_len = line_width
292 .saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(curr_line.text_lenrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]text_len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().wrap_config.right_prefix_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#right_prefix_symbol..widthrust-analyzer cargo unicode-width 0.1.14 impl#[str][UnicodeWidthStr]width().());
293
294 if wrap_config.use_wrap_right_permillerust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#use_wrap_right_permille. 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().current_permille && pad_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().0 {
295 // The inserted spaces, which align a line to the right, point into this string.
296 const SPACESrust-analyzer cargo git-delta 0.19.2 wrapping/SPACES.: &str = " ";
297
298 match result.last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().() {
299 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref mut vec) if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().vec.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() => {
300 vec.last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().1 = &wrap_config.right_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#right_symbol.
301 }
302 _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("wrap result must not be empty"),
303 }
304
305 let mut right_aligned_line = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
306
307 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(pad_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().SPACESrust-analyzer cargo git-delta 0.19.2 wrapping/SPACES..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()) {
308 right_aligned_line.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().fill_style, SPACESrust-analyzer cargo git-delta 0.19.2 wrapping/SPACES.));
309 }
310
311 match pad_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().SPACESrust-analyzer cargo git-delta 0.19.2 wrapping/SPACES..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() {
312 0 => (),
313 n => right_aligned_line.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().fill_style, &SPACESrust-analyzer cargo git-delta 0.19.2 wrapping/SPACES.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)),
314 }
315
316 right_aligned_line.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((symbol_style, &wrap_config.right_prefix_symbolrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#right_prefix_symbol.));
317
318 right_aligned_line.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(curr_line.line_segmentsrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#line_segments.);
319
320 curr_line.line_segmentsrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#line_segments. = right_aligned_line;
321
322 // curr_line.len not updated, as only 0 / >0 for `has_text()` is required.
323 }
324 }
325
326 if curr_line.has_textrust-analyzer cargo git-delta 0.19.2 wrapping/impl#[`CurrLine<'a, S>`]has_text().() {
327 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(curr_line.line_segmentsrust-analyzer cargo git-delta 0.19.2 wrapping/CurrLine#line_segments.);
328 }
329
330 if stop rust-analyzer cargo git-delta 0.19.2 wrapping/impl#[Stop][`PartialEq<Self>`]eq().==rust-analyzer cargo git-delta 0.19.2 wrapping/impl#[Stop][`PartialEq<Self>`]eq(). rust-analyzer cargo git-delta 0.19.2 wrapping/impl#[Stop][`PartialEq<Self>`]eq().Stoprust-analyzer cargo git-delta 0.19.2 wrapping/Stop#::LineLimitrust-analyzer cargo git-delta 0.19.2 wrapping/Stop#LineLimit# && result.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][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().max_lines {
331 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
332 }
333
334 // Anything that is left will be added to the (last) line. If this is too long it will
335 // be truncated later.
336 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().stack.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
337 if result.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
338 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
339 }
340
341 // unwrap: previous `if` ensures result can not be empty
342 result.last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(stack.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().());
343 }
344
345 result
346 }
347
348 fn wrap_if_too_longrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_if_too_long().<'a, S>(
349 config: &'a Configrust-analyzer cargo git-delta 0.19.2 config/Config#,
350 wrapped: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, S>>,
351 input_vec: LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, S>,
352 must_wrap: bool,
353 line_width: usize,
354 fill_style: &S,
355 inline_hint_style: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<S>,
356 ) -> (usize, usize)
357 where
358 S: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
359 {
360 let size_prev = wrapped.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
361
362 if must_wrap {
363 wrapped.appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut wrap_linerust-analyzer cargo git-delta 0.19.2 wrapping/wrap_line().(
364 config,
365 input_vec,
366 line_width,
367 fill_style,
368 inline_hint_style,
369 ));
370 } else {
371 wrapped.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(input_vec.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().());
372 }
373
374 (size_prev, wrapped.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().())
375 }
376
377 /// Call [`wrap_line`] for the `syntax` and the `diff` lines if `wrapinfo` says
378 /// a specific line was longer than `line_width`. Return an adjusted `alignment`
379 /// with regard to the added wrapped lines.
380 #[allow(clippy::comparison_chain, clippy::type_complexity)]
381 pub fn wrap_minusplus_blockrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_minusplus_block().<'c: 'a, 'a>(
382 config: &'c Configrust-analyzer cargo git-delta 0.19.2 config/Config#,
383 syntax: MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>>>,
384 diff: MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>>>,
385 alignment: &[(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>)],
386 line_width: &SideBySideLineWidthrust-analyzer cargo git-delta 0.19.2 features/line_numbers/SideBySideLineWidth#,
387 wrapinfo: &'a MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<bool>>,
388 ) -> (
389 Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>)>,
390 MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Staterust-analyzer cargo git-delta 0.19.2 delta/State#>>,
391 MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>>>,
392 MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>>>,
393 ) {
394 let mut new_alignment = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
395 let mut new_states = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Staterust-analyzer cargo git-delta 0.19.2 delta/State#>>::defaultrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][Default]default().();
396 let mut new_wrapped_syntax = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::defaultrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][Default]default().();
397 let mut new_wrapped_diff = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::defaultrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][Default]default().();
398
399 // Turn all these into pairs of iterators so they can be advanced according
400 // to the alignment and independently.
401 let mut syntax = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().(syntax.minusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#minus..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), syntax.plusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#plus..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
402 let mut diff = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().(diff.minusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#minus..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), diff.plusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#plus..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
403 let mut wrapinfo = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().(wrapinfo[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), wrapinfo[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().());
404
405 let fill_style = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().(&config.minus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_style., &config.plus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_style.);
406
407 // Internal helper function to perform wrapping for both the syntax and the
408 // diff highlighting (SyntectStyle and Style).
409 #[allow(clippy::too_many_arguments)]
410 pub fn wrap_syntax_and_diffrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_syntax_and_diff().<'a, ItSyn, ItDiff, ItWrap>(
411 config: &'a Configrust-analyzer cargo git-delta 0.19.2 config/Config#,
412 wrapped_syntax: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>>,
413 wrapped_diff: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>>,
414 syntax_iter: &mut ItSyn,
415 diff_iter: &mut ItDiff,
416 wrapinfo_iter: &mut ItWrap,
417 line_width: usize,
418 fill_style: &Stylerust-analyzer cargo git-delta 0.19.2 style/Style#,
419 errhint: &'a str,
420 ) -> (usize, usize)
421 where
422 ItSyn: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>>,
423 ItDiff: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>>,
424 ItWrap: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &'a bool>,
425 {
426 let must_wrap = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().wrapinfo_iter
427 .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#next().()
428 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("bad wrap info {}", errhint));
429
430 let (start, extended_to) = wrap_if_too_longrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_if_too_long().(
431 config,
432 wrapped_syntax,
433 syntax_iter
434 .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#next().()
435 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("bad syntax alignment {}", errhint)),
436 must_wrap,
437 line_width,
438 &config.null_syntect_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_syntect_style.,
439 &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.wrap_configrust-analyzer cargo git-delta 0.19.2 config/Config#wrap_config..inline_hint_syntect_stylerust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#inline_hint_syntect_style.),
440 );
441
442 // TODO: Why is the background color set to white when
443 // ansi_term_style.background is None?
444 let inline_hint_style = if config
445 .inline_hint_stylerust-analyzer cargo git-delta 0.19.2 config/Config#inline_hint_style.
446 .ansi_term_stylerust-analyzer cargo git-delta 0.19.2 style/Style#ansi_term_style.
447 .backgroundrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#background.
448 .is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()
449 {
450 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.inline_hint_stylerust-analyzer cargo git-delta 0.19.2 config/Config#inline_hint_style.)
451 } else {
452 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
453 };
454
455 let (start2, extended_to2) = wrap_if_too_longrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_if_too_long().(
456 config,
457 wrapped_diff,
458 diff_iter
459 .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#next().()
460 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("bad diff alignment {}", errhint)),
461 must_wrap,
462 line_width,
463 fill_style,
464 &inline_hint_style,
465 );
466
467 // The underlying text is the same for the style and diff, so
468 // the length of the wrapping should be identical:
469 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
470 (start, extended_to),
471 (start2, extended_to2),
472 "syntax and diff wrapping differs {errhint}",
473 );
474
475 (start, extended_to)
476 }
477
478 // This macro avoids having the same code block 4x in the alignment processing
479 macro_rules! wrap_and_assertrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_and_assert! {
480 ($side:tt, $errhint:tt, $have:tt, $expected:tt) => {{
481 assert_eq!(*$have, $expected, "bad alignment index {}", $errhint);
482 $expected += 1;
483
484 wrap_syntax_and_diff(
485 &config,
486 &mut new_wrapped_syntax[$side],
487 &mut new_wrapped_diff[$side],
488 &mut syntax[$side],
489 &mut diff[$side],
490 &mut wrapinfo[$side],
491 line_width[$side],
492 &fill_style[$side],
493 $errhint,
494 )
495 }};
496 }
497
498 let mut m_expected = 0;
499 let mut p_expected = 0;
500
501 // Process blocks according to the alignment and build a new alignment.
502 // If lines get added via wrapping these are assigned the state HunkMinusWrapped/HunkPlusWrapped.
503 for (minus, plus) in alignment {
504 let (minus_extended, plus_extended) = match (minus, plus) {
505 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(m), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => {
506 let (minus_start, extended_to) = wrap_and_assertrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_and_assert!!(Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#, "[*l*] (-)", m, m_expected);
507
508 for i in minus_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#extended_to {
509 new_alignment.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#));
510 }
511
512 (extended_to rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().minus_start, 0)
513 }
514 (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#(p)) => {
515 let (plus_start, extended_to) = wrap_and_assertrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_and_assert!!(Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#, "(-) [*r*]", p, p_expected);
516
517 for i in plus_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#extended_to {
518 new_alignment.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((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#(i)));
519 }
520
521 (0, extended_to rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().plus_start)
522 }
523 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(m), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(p)) => {
524 let (minus_start, m_extended_to) =
525 wrap_and_assertrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_and_assert!!(Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#, "[*l*] (r)", m, m_expected);
526 let (plus_start, p_extended_to) =
527 wrap_and_assertrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_and_assert!!(Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#, "(l) [*r*]", p, p_expected);
528
529 for (new_m, new_p) in (minus_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#m_extended_to).ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(plus_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#p_extended_to) {
530 new_alignment.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(new_m), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(new_p)));
531 }
532
533 // This Some(m):Some(p) alignment might have become uneven, so fill
534 // up the shorter side with None.
535
536 let minus_extended = m_extended_to rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().minus_start;
537 let plus_extended = p_extended_to rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().plus_start;
538
539 let plus_minus = (minus_extended as isize) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub().(plus_extended as isize);
540
541 if plus_minus rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt().0 {
542 for m in (m_extended_to as isize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub().plus_minus) as usize..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#m_extended_to {
543 new_alignment.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(m), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#));
544 }
545 } else if plus_minus rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().0 {
546 for p in (p_extended_to as isize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().plus_minus) as usize..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#p_extended_to {
547 new_alignment.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((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#(p)));
548 }
549 }
550
551 (minus_extended, plus_extended)
552 }
553 _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("None-None alignment"),
554 };
555
556 if minus_extended 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().0 {
557 new_states[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut().Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut()..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#::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#));
558 for _ in 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#minus_extended {
559 new_states[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut().Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut()..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinusWrapped#);
560 }
561 }
562 if plus_extended 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().0 {
563 new_states[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut().Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut()..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#::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#));
564 for _ in 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#plus_extended {
565 new_states[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut().Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut()..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlusWrapped#);
566 }
567 }
568 }
569
570 (
571 new_alignment,
572 new_states,
573 new_wrapped_syntax,
574 new_wrapped_diff,
575 )
576 }
577
578 #[allow(clippy::comparison_chain, clippy::type_complexity)]
579 pub fn wrap_zero_blockrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_zero_block().<'c: 'a, 'a>(
580 config: &'c Configrust-analyzer cargo git-delta 0.19.2 config/Config#,
581 line: &str,
582 mut states: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Staterust-analyzer cargo git-delta 0.19.2 delta/State#>,
583 syntax_style_sections: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>>,
584 diff_style_sections: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>>,
585 line_numbers_data: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::LineNumbersDatarust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#>,
586 ) -> (
587 Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Staterust-analyzer cargo git-delta 0.19.2 delta/State#>,
588 Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>>,
589 Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>>,
590 ) {
591 // The width is the minimum of the left/right side. The panels should be equally sized,
592 // but in rare cases the remaining panel width might differ due to the space the line
593 // numbers take up.
594 let line_width = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line_numbers_data) = line_numbers_data {
595 let width = available_line_widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/available_line_width().(config, line_numbers_data);
596 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().(width[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index()., width[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().)
597 } else {
598 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().(
599 config.side_by_side_datarust-analyzer cargo git-delta 0.19.2 config/Config#side_by_side_data.[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index()..widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel#width.,
600 config.side_by_side_datarust-analyzer cargo git-delta 0.19.2 config/Config#side_by_side_data.[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index()..widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel#width.,
601 )
602 };
603
604 // Called with a single line, so no need to use the 1-sized bool vector.
605 // If that changes the wrapping logic should be updated as well.
606 debug_assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_eq!!(diff_style_sections.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
607
608 let should_wrap = line_is_too_longrust-analyzer cargo git-delta 0.19.2 features/side_by_side/line_is_too_long().(line, line_width);
609
610 if should_wrap {
611 let syntax_style = wrap_linerust-analyzer cargo git-delta 0.19.2 wrapping/wrap_line().(
612 config,
613 syntax_style_sections.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flatten().(),
614 line_width,
615 &SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#::defaultrust-analyzer cargo syntect 5.3.0 highlighting/style/impl#[Style][Default]default().(),
616 &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.wrap_configrust-analyzer cargo git-delta 0.19.2 config/Config#wrap_config..inline_hint_syntect_stylerust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#inline_hint_syntect_style.),
617 );
618
619 // TODO: Why is the background color set to white when
620 // ansi_term_style.background is None?
621 let inline_hint_style = if config
622 .inline_hint_stylerust-analyzer cargo git-delta 0.19.2 config/Config#inline_hint_style.
623 .ansi_term_stylerust-analyzer cargo git-delta 0.19.2 style/Style#ansi_term_style.
624 .backgroundrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#background.
625 .is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()
626 {
627 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.inline_hint_stylerust-analyzer cargo git-delta 0.19.2 config/Config#inline_hint_style.)
628 } else {
629 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
630 };
631 let diff_style = wrap_linerust-analyzer cargo git-delta 0.19.2 wrapping/wrap_line().(
632 config,
633 diff_style_sections.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flatten().(),
634 line_width,
635 // To actually highlight inline hint characters:
636 &Stylerust-analyzer cargo git-delta 0.19.2 style/Style# {
637 is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted.: true,
638 ..config.null_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_style.
639 },
640 &inline_hint_style,
641 );
642
643 states.resize_withrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]resize_with().(syntax_style.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), || Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZeroWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkZeroWrapped#);
644
645 (states, syntax_style, diff_style)
646 } else {
647 (states, syntax_style_sections, diff_style_sections)
648 }
649 }
650
651 #[cfg(test)]
652 mod testsrust-analyzer cargo git-delta 0.19.2 wrapping/tests/ {
653 use lazy_staticrust-analyzer cargo lazy_static 1.4.0 crate/::lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!;
654 use syntectrust-analyzer cargo syntect 5.3.0 crate/::highlightingrust-analyzer cargo syntect 5.3.0 highlighting/::Stylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style# as SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#;
655
656 use superrust-analyzer cargo git-delta 0.19.2 wrapping/::wrap_linerust-analyzer cargo git-delta 0.19.2 wrapping/wrap_line().;
657 use superrust-analyzer cargo git-delta 0.19.2 wrapping/::WrapConfigrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#;
658 use craterust-analyzer cargo git-delta 0.19.2 crate/::configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#;
659 use craterust-analyzer cargo git-delta 0.19.2 crate/::paintrust-analyzer cargo git-delta 0.19.2 paint/::LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#;
660 use craterust-analyzer cargo git-delta 0.19.2 crate/::stylerust-analyzer cargo git-delta 0.19.2 style/::Stylerust-analyzer cargo git-delta 0.19.2 style/Style#;
661 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/::{make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args()., DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#};
662
663 lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! {
664 static ref S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1#: Stylerust-analyzer cargo git-delta 0.19.2 style/Style# = Stylerust-analyzer cargo git-delta 0.19.2 style/Style# {
665 is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted.: true,
666 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo git-delta 0.19.2 style/impl#[Style][Default]default().()
667 };
668 }
669 lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! {
670 static ref S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2#: Stylerust-analyzer cargo git-delta 0.19.2 style/Style# = Stylerust-analyzer cargo git-delta 0.19.2 style/Style# {
671 is_emphrust-analyzer cargo git-delta 0.19.2 style/Style#is_emph.: true,
672 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo git-delta 0.19.2 style/impl#[Style][Default]default().()
673 };
674 }
675 lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! {
676 static ref SYrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SY#: SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style# = SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#::defaultrust-analyzer cargo syntect 5.3.0 highlighting/style/impl#[Style][Default]default().();
677 }
678 lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! {
679 static ref SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD#: Stylerust-analyzer cargo git-delta 0.19.2 style/Style# = Stylerust-analyzer cargo git-delta 0.19.2 style/Style#::defaultrust-analyzer cargo git-delta 0.19.2 style/impl#[Style][Default]default().();
680 }
681
682 const Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.: &str = "+"; // wrap
683 const WRrust-analyzer cargo git-delta 0.19.2 wrapping/tests/WR.: &str = "<"; // wrap-right
684 const RArust-analyzer cargo git-delta 0.19.2 wrapping/tests/RA.: &str = ">"; // right-align
685
686 lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! {
687 static ref WRAP_DEFAULT_ARGSrust-analyzer cargo git-delta 0.19.2 wrapping/tests/WRAP_DEFAULT_ARGS#: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&'static str> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
688 "--wrap-left-symbol",
689 Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.,
690 "--wrap-right-symbol",
691 WRrust-analyzer cargo git-delta 0.19.2 wrapping/tests/WR.,
692 "--wrap-right-prefix-symbol",
693 RArust-analyzer cargo git-delta 0.19.2 wrapping/tests/RA.,
694 "--wrap-max-lines",
695 "4",
696 "--wrap-right-percent",
697 "37.0%",
698 ];
699 }
700
701 lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! {
702 static ref TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG#: WrapConfigrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig# =
703 make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&WRAP_DEFAULT_ARGSrust-analyzer cargo git-delta 0.19.2 wrapping/tests/WRAP_DEFAULT_ARGS.).wrap_configrust-analyzer cargo git-delta 0.19.2 config/Config#wrap_config.;
704 }
705
706 fn default_wrap_cfg_plusrust-analyzer cargo git-delta 0.19.2 wrapping/tests/default_wrap_cfg_plus().<'a>(args: &[&'a str]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&'a str> {
707 let mut result = WRAP_DEFAULT_ARGSrust-analyzer cargo git-delta 0.19.2 wrapping/tests/WRAP_DEFAULT_ARGS..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
708 result.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(args);
709 result
710 }
711
712 fn mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(wrap_cfg: &WrapConfigrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#) -> Configrust-analyzer cargo git-delta 0.19.2 config/Config# {
713 let mut cfg: Configrust-analyzer cargo git-delta 0.19.2 config/Config# = make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&[]);
714 cfg.wrap_configrust-analyzer cargo git-delta 0.19.2 config/Config#wrap_config. = wrap_cfg.clonerust-analyzer cargo git-delta 0.19.2 wrapping/impl#[WrapConfig][Clone]clone().();
715 cfg
716 }
717
718 fn wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().<'a, I, S>(cfg: &'a Configrust-analyzer cargo git-delta 0.19.2 config/Config#, line: I, line_width: usize) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, S>>
719 where
720 I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (S, &'a str)> + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
721 <I as IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#>::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#: DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#,
722 S: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
723 {
724 wrap_linerust-analyzer cargo git-delta 0.19.2 wrapping/wrap_line().(cfg, line, line_width, &S::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().(), &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
725 }
726
727 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
728 fn test_wrap_line_singlerust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_wrap_line_single().() {
729 let cfg = mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(&TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG.);
730
731 {
732 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SY][Deref]deref().SYrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SY., "0")];
733 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
734 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SY][Deref]deref().SYrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SY., "0")]]);
735 }
736 {
737 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "012"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "34")];
738 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
739 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "012"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "34")]]);
740 }
741 {
742 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "012"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "345")];
743 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
744 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "012"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "345")]]);
745 }
746 {
747 // Empty input usually does not happen
748 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "")];
749 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
750 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(lines.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
751 }
752 {
753 // Partially empty should not happen either
754 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "0")];
755 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
756 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "0")]]);
757 }
758 {
759 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "0"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "")];
760 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
761 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "0"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "")]]);
762 }
763 {
764 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
765 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "0"),
766 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., ""),
767 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""),
768 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., ""),
769 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""),
770 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., ""),
771 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""),
772 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., ""),
773 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""),
774 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., ""),
775 ];
776 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
777 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
778 lines,
779 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
780 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "0"),
781 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., ""),
782 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""),
783 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., ""),
784 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""),
785 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., ""),
786 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""),
787 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., ""),
788 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., ""),
789 (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "")
790 ]]
791 );
792 }
793 }
794
795 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
796 fn test_wrap_line_align_right_1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_wrap_line_align_right_1().() {
797 let cfg = mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(&TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG.);
798
799 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "0123456789ab")];
800 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 11);
801 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
802 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().1, WRrust-analyzer cargo git-delta 0.19.2 wrapping/tests/WR.);
803 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., [(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., " "), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., ">"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "ab")]);
804 }
805
806 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
807 fn test_wrap_line_align_right_2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_wrap_line_align_right_2().() {
808 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "012"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "3456")];
809
810 {
811 // Right align lines on the second line
812 let cfg = mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(&TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG.);
813
814 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(), 6);
815 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
816 lines,
817 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
818 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "012"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "34"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., WRrust-analyzer cargo git-delta 0.19.2 wrapping/tests/WR.)],
819 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., " "), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., RArust-analyzer cargo git-delta 0.19.2 wrapping/tests/RA.), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "56")]
820 ]
821 );
822 }
823
824 {
825 // Set right align percentage lower, normal wrapping
826 let mut no_align_right = TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG..clonerust-analyzer cargo git-delta 0.19.2 wrapping/impl#[WrapConfig][Clone]clone().();
827 no_align_right.use_wrap_right_permillerust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#use_wrap_right_permille. = 1; // 0.1%
828 let cfg_no_align_right = mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(&no_align_right);
829
830 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg_no_align_right, line, 6);
831 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
832 lines,
833 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "012"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "34"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "56")]]
834 );
835 }
836 }
837
838 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
839 fn test_wrap_line_newlinesrust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_wrap_line_newlines().() {
840 fn mk_inputrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input().(len: usize) -> LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'static, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#> {
841 const INrust-analyzer cargo git-delta 0.19.2 wrapping/tests/IN.: &str = "0123456789abcdefZ";
842 let v = &[*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., *rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2.];
843 let s1s2 = v.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().cyclerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cycle().();
844 let text: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = INrust-analyzer cargo git-delta 0.19.2 wrapping/tests/IN..matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]matches().(|_| true).takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
845 s1s2.ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(text.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().())
846 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(style, text)| (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().style, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().text))
847 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
848 }
849 fn mk_input_nlrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input_nl().(len: usize) -> LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'static, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#> {
850 const NLrust-analyzer cargo git-delta 0.19.2 wrapping/tests/NL.: &str = "\n";
851 let mut line = mk_inputrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input().(len);
852 line.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., NLrust-analyzer cargo git-delta 0.19.2 wrapping/tests/NL.));
853 line
854 }
855 fn mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().<'a>(
856 vec: &LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>,
857 from: usize,
858 to: usize,
859 append: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, &'a str)>,
860 ) -> LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#> {
861 let mut result: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = vec[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().from..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#to]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
862 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) = append {
863 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(val);
864 }
865 result
866 }
867
868 let cfg = mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(&TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG.);
869
870 {
871 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "012"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "345\n")];
872 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
873 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "012"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "345\n")]]);
874 }
875
876 {
877 for i in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#5 {
878 let line = mk_inputrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input().(i);
879 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
880 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![mk_inputrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input().(i)]);
881
882 let line = mk_input_nlrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input_nl().(i);
883 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 6);
884 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![mk_input_nlrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input_nl().(i)]);
885 }
886 }
887
888 {
889 let line = mk_input_nlrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input_nl().(9);
890 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 3);
891 let expected = mk_input_nlrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input_nl().(9);
892 let line1 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 0, 2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)));
893 let line2 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 2, 4, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)));
894 let line3 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 4, 6, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)));
895 let line4 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 6, 8, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)));
896 let line5 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 8, 11, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
897 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![line1, line2, line3, line4, line5]);
898 }
899
900 {
901 let line = mk_input_nlrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input_nl().(10);
902 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 3);
903 let expected = mk_input_nlrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_input_nl().(10);
904 let line1 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 0, 2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)));
905 let line2 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 2, 4, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)));
906 let line3 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 4, 6, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)));
907 let line4 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 6, 8, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)));
908 let line5 = mk_expectedrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_expected().(&expected, 8, 11, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "\n")));
909 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![line1, line2, line3, line4, line5]);
910 }
911
912 {
913 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "abc"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "01230123012301230123"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "ZZZZZ")];
914
915 let wcfg1 = mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(&WrapConfigrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig# {
916 max_linesrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#max_lines.: 1,
917 ..TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG..clonerust-analyzer cargo git-delta 0.19.2 wrapping/impl#[WrapConfig][Clone]clone().()
918 });
919 let wcfg2 = mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(&WrapConfigrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig# {
920 max_linesrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#max_lines.: 2,
921 ..TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG..clonerust-analyzer cargo git-delta 0.19.2 wrapping/impl#[WrapConfig][Clone]clone().()
922 });
923 let wcfg3 = mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(&WrapConfigrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig# {
924 max_linesrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#max_lines.: 3,
925 ..TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG..clonerust-analyzer cargo git-delta 0.19.2 wrapping/impl#[WrapConfig][Clone]clone().()
926 });
927
928 let lines = wrap_linerust-analyzer cargo git-delta 0.19.2 wrapping/wrap_line().(&wcfg1, line.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(), 4, &Stylerust-analyzer cargo git-delta 0.19.2 style/Style#::defaultrust-analyzer cargo git-delta 0.19.2 style/impl#[Style][Default]default().(), &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
929 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
930 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().1, "ZZZZZ");
931 let lines = wrap_linerust-analyzer cargo git-delta 0.19.2 wrapping/wrap_line().(&wcfg2, line.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(), 4, &Stylerust-analyzer cargo git-delta 0.19.2 style/Style#::defaultrust-analyzer cargo git-delta 0.19.2 style/impl#[Style][Default]default().(), &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
932 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
933 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().1, "ZZZZZ");
934 let lines = wrap_linerust-analyzer cargo git-delta 0.19.2 wrapping/wrap_line().(&wcfg3, line.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(), 4, &Stylerust-analyzer cargo git-delta 0.19.2 style/Style#::defaultrust-analyzer cargo git-delta 0.19.2 style/impl#[Style][Default]default().(), &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
935 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 3);
936 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lines.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().1, "ZZZZZ");
937 }
938 }
939
940 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
941 fn test_wrap_line_unicoderust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_wrap_line_unicode().() {
942 let cfg = mk_wrap_cfgrust-analyzer cargo git-delta 0.19.2 wrapping/tests/mk_wrap_cfg().(&TEST_WRAP_CFGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/TEST_WRAP_CFG.);
943
944 // from UnicodeSegmentation documentation and the linked
945 // Unicode Standard Annex #29
946 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "abc"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "mnö̲"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "xyz")];
947 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 4);
948 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
949 lines,
950 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
951 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "abc"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)],
952 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "mnö̲"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)],
953 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "xyz")]
954 ]
955 );
956
957 // Not working: Tailored grapheme clusters: क्षि = क् + षि
958 //
959 // Difference compare to previous example (even they may look like the
960 // same width in text editor.) :
961 //
962 // width நி: 2
963 // width ö̲: 1
964 let line = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "abc"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "dநி"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "ghij")];
965 let lines = wrap_testrust-analyzer cargo git-delta 0.19.2 wrapping/tests/wrap_test().(&cfg, line, 4);
966 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
967 lines,
968 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
969 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "abc"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)],
970 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S2][Deref]deref().S2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S2., "dநி"), (*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[SD][Deref]deref().SDrust-analyzer cargo git-delta 0.19.2 wrapping/tests/SD., Wrust-analyzer cargo git-delta 0.19.2 wrapping/tests/W.)],
971 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 wrapping/tests/impl#[S1][Deref]deref().S1rust-analyzer cargo git-delta 0.19.2 wrapping/tests/S1., "ghij")]
972 ]
973 );
974 }
975
976 const HUNK_ZERO_DIFFrust-analyzer cargo git-delta 0.19.2 wrapping/tests/HUNK_ZERO_DIFF.: &str = "\
977 diff --git i/a.py w/a.py
978 index 223ca50..e69de29 100644
979 --- i/a.py
980 +++ w/a.py
981 @@ -4,3 +15,3 @@
982 abcdefghijklmnopqrstuvwxzy 0123456789 0123456789 0123456789 0123456789 0123456789
983 -a = 1
984 +a = 2
985 ";
986
987 const HUNK_ZERO_LARGE_LINENUMBERS_DIFFrust-analyzer cargo git-delta 0.19.2 wrapping/tests/HUNK_ZERO_LARGE_LINENUMBERS_DIFF.: &str = "\
988 diff --git i/a.py w/a.py
989 index 223ca50..e69de29 100644
990 --- i/a.py
991 +++ w/a.py
992 @@ -10,3 +101999,3 @@
993 abcdefghijklmnopqrstuvwxzy 0123456789 0123456789 0123456789 0123456789 0123456789
994 -a = 1
995 +a = 2
996 ";
997
998 const HUNK_MP_DIFFrust-analyzer cargo git-delta 0.19.2 wrapping/tests/HUNK_MP_DIFF.: &str = "\
999 diff --git i/a.py w/a.py
1000 index 223ca50..e69de29 100644
1001 --- i/a.py
1002 +++ w/a.py
1003 @@ -4,3 +15,3 @@
1004 abcdefghijklmnopqrstuvwxzy 0123456789 0123456789 0123456789 0123456789 0123456789
1005 -a = 0123456789 0123456789 0123456789 0123456789 0123456789
1006 +b = 0123456789 0123456789 0123456789 0123456789 0123456789
1007 ";
1008
1009 const HUNK_ALIGN_DIFF_HEADERrust-analyzer cargo git-delta 0.19.2 wrapping/tests/HUNK_ALIGN_DIFF_HEADER.: &str = "--- a\n+++ b\n@@ -1,1 +1,1 @@\n";
1010 const HUNK_ALIGN_DIFF_SHORTrust-analyzer cargo git-delta 0.19.2 wrapping/tests/HUNK_ALIGN_DIFF_SHORT.: &str = ".........1.........2....\n";
1011 const HUNK_ALIGN_DIFF_LONGrust-analyzer cargo git-delta 0.19.2 wrapping/tests/HUNK_ALIGN_DIFF_LONG.: &str =
1012 ".........1.........2.........3.........4.........5.........6\n";
1013
1014 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1015 fn test_wrap_with_unequal_hunk_zero_widthrust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_wrap_with_unequal_hunk_zero_width().() {
1016 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().(&default_wrap_cfg_plusrust-analyzer cargo git-delta 0.19.2 wrapping/tests/default_wrap_cfg_plus().(&[
1017 "--side-by-side",
1018 "--line-numbers-left-format",
1019 "│L│",
1020 "--line-numbers-right-format",
1021 "│RRRR│",
1022 "--width",
1023 "40",
1024 "--line-fill-method",
1025 "spaces",
1026 ]))
1027 .set_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]set_config().(|cfg| cfg.truncation_symbolrust-analyzer cargo git-delta 0.19.2 config/Config#truncation_symbol. = ">".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
1028 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(HUNK_ZERO_DIFFrust-analyzer cargo git-delta 0.19.2 wrapping/tests/HUNK_ZERO_DIFF.)
1029 .expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(
1030 r#"
1031 │L│abcdefghijklm+ │RRRR│abcdefghijklm+
1032 │L│nopqrstuvwxzy+ │RRRR│nopqrstuvwxzy+
1033 │L│ 0123456789 0+ │RRRR│ 0123456789 0+
1034 │L│123456789 012+ │RRRR│123456789 012+
1035 │L│3456789 01234567>│RRRR│3456789 01234>
1036 │L│a = 1 │RRRR│a = 2 "#,
1037 );
1038 }
1039
1040 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1041 fn test_wrap_with_large_hunk_zero_line_numbersrust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_wrap_with_large_hunk_zero_line_numbers().() {
1042 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().(&default_wrap_cfg_plusrust-analyzer cargo git-delta 0.19.2 wrapping/tests/default_wrap_cfg_plus().(&[
1043 "--side-by-side",
1044 "--line-numbers-left-format",
1045 "│LLL│",
1046 "--line-numbers-right-format",
1047 "│WW {nm} +- {np:2} WW│",
1048 "--width",
1049 "60",
1050 "--line-fill-method",
1051 "ansi",
1052 ]))
1053 .set_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]set_config().(|cfg| cfg.truncation_symbolrust-analyzer cargo git-delta 0.19.2 config/Config#truncation_symbol. = ">".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
1054 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(HUNK_ZERO_LARGE_LINENUMBERS_DIFFrust-analyzer cargo git-delta 0.19.2 wrapping/tests/HUNK_ZERO_LARGE_LINENUMBERS_DIFF.)
1055 .expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(
1056 r#"
1057 │LLL│abcde+ │WW 10 +- 101999 WW│abcde+
1058 │LLL│fghij+ │WW +- WW│fghij+
1059 │LLL│klmno+ │WW +- WW│klmno+
1060 │LLL│pqrst+ │WW +- WW│pqrst+
1061 │LLL│uvwxzy 0123456789 012345>│WW +- WW│uvwxz>
1062 │LLL│a = 1 │WW +- 102000 WW│a = 2"#,
1063 );
1064 }
1065
1066 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1067 fn test_wrap_with_keep_markersrust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_wrap_with_keep_markers().() {
1068 use craterust-analyzer cargo git-delta 0.19.2 crate/::featuresrust-analyzer cargo git-delta 0.19.2 features/::side_by_siderust-analyzer cargo git-delta 0.19.2 features/side_by_side/::ansifillrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/::ODD_PAD_CHARrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/ODD_PAD_CHAR.;
1069 let t = 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().(&default_wrap_cfg_plusrust-analyzer cargo git-delta 0.19.2 wrapping/tests/default_wrap_cfg_plus().(&[
1070 "--side-by-side",
1071 "--keep-plus-minus-markers",
1072 "--width",
1073 "45",
1074 ]))
1075 .set_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]set_config().(|cfg| cfg.truncation_symbolrust-analyzer cargo git-delta 0.19.2 config/Config#truncation_symbol. = ">".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
1076 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(HUNK_MP_DIFFrust-analyzer cargo git-delta 0.19.2 wrapping/tests/HUNK_MP_DIFF.)
1077 .expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(
1078 r#"
1079 │ 4 │ abcdefghijklmn+ │ 15 │ abcdefghijklmn+
1080 │ │ opqrstuvwxzy 0+ │ │ opqrstuvwxzy 0+
1081 │ │ 123456789 0123+ │ │ 123456789 0123+
1082 │ │ 456789 0123456+ │ │ 456789 0123456+
1083 │ │ 789 0123456789> │ │ 789 0123456789>
1084 │ 5 │-a = 0123456789+ │ 16 │+b = 0123456789+
1085 │ │ 0123456789 01+ │ │ 0123456789 01+
1086 │ │ 23456789 01234+ │ │ 23456789 01234+
1087 │ │ 56789 01234567+ │ │ 56789 01234567+
1088 │ │ 89 │ │ 89"#,
1089 // this column here is^ where ODD_PAD_CHAR is inserted due to the odd 45 width
1090 );
1091
1092 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().t.outputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTestOutput#output..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().());
1093
1094 for line in t.outputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTestOutput#output..linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().skiprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#skip().(craterust-analyzer cargo git-delta 0.19.2 crate/::configrust-analyzer cargo git-delta 0.19.2 config/::HEADER_LENrust-analyzer cargo git-delta 0.19.2 config/HEADER_LEN.) {
1095 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(line.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(22), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ODD_PAD_CHARrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/ODD_PAD_CHAR.));
1096 }
1097 }
1098
1099 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1100 fn test_alignment_2_lines_vs_3_linesrust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_alignment_2_lines_vs_3_lines().() {
1101 let config =
1102 make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&default_wrap_cfg_plusrust-analyzer cargo git-delta 0.19.2 wrapping/tests/default_wrap_cfg_plus().(&["--side-by-side", "--width", "55"]));
1103
1104 {
1105 DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_config().(&config)
1106 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1107 "{HUNK_ALIGN_DIFF_HEADER}-{HUNK_ALIGN_DIFF_SHORT}+{HUNK_ALIGN_DIFF_LONG}",
1108 ))
1109 .expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(
1110 r#"
1111 │ 1 │.........1.........2< │ 1 │.........1.........2+
1112 │ │ >.... │ │.........3.........4+
1113 │ │ │ │.........5.........6"#,
1114 );
1115 // the place where ODD_PAD_CHAR^ is inserted due to the odd 55 width
1116 }
1117
1118 {
1119 DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_config().(&config)
1120 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1121 "{HUNK_ALIGN_DIFF_HEADER}-{HUNK_ALIGN_DIFF_LONG}+{HUNK_ALIGN_DIFF_SHORT}",
1122 ))
1123 .expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(
1124 r#"
1125 │ 1 │.........1.........2+ │ 1 │.........1.........2<
1126 │ │.........3.........4+ │ │ >....
1127 │ │.........5.........6 │ │"#,
1128 );
1129 }
1130 }
1131
1132 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1133 fn test_alignment_1_line_vs_3_linesrust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_alignment_1_line_vs_3_lines().() {
1134 let config = make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&default_wrap_cfg_plusrust-analyzer cargo git-delta 0.19.2 wrapping/tests/default_wrap_cfg_plus().(&[
1135 "--side-by-side",
1136 "--width",
1137 "61",
1138 "--line-fill-method",
1139 "spaces",
1140 ]));
1141
1142 {
1143 DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_config().(&config)
1144 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1145 "{HUNK_ALIGN_DIFF_HEADER}-{HUNK_ALIGN_DIFF_SHORT}+{HUNK_ALIGN_DIFF_LONG}",
1146 ))
1147 .expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(
1148 r#"
1149 │ 1 │.........1.........2....│ 1 │.........1.........2...+
1150 │ │ │ │......3.........4......+
1151 │ │ │ │...5.........6 "#,
1152 );
1153 }
1154
1155 {
1156 DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_config().(&config)
1157 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1158 "{HUNK_ALIGN_DIFF_HEADER}-{HUNK_ALIGN_DIFF_LONG}+{HUNK_ALIGN_DIFF_SHORT}",
1159 ))
1160 .expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(
1161 r#"
1162 │ 1 │.........1.........2...+│ 1 │.........1.........2....
1163 │ │......3.........4......+│ │
1164 │ │...5.........6 │ │"#,
1165 );
1166 }
1167 }
1168
1169 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1170 fn test_wrap_max_lines_2rust-analyzer cargo git-delta 0.19.2 wrapping/tests/test_wrap_max_lines_2().() {
1171 // TODO overriding is not possible, need to change config directly
1172 let mut config = make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&default_wrap_cfg_plusrust-analyzer cargo git-delta 0.19.2 wrapping/tests/default_wrap_cfg_plus().(&[
1173 // "--wrap-max-lines",
1174 // "2",
1175 "--side-by-side",
1176 "--width",
1177 "72",
1178 "--line-fill-method",
1179 "spaces",
1180 ]));
1181 config.truncation_symbolrust-analyzer cargo git-delta 0.19.2 config/Config#truncation_symbol. = ">".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
1182
1183 {
1184 DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_config().(&config)
1185 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1186 "{HUNK_ALIGN_DIFF_HEADER}-{HUNK_ALIGN_DIFF_SHORT}+{HUNK_ALIGN_DIFF_LONG}",
1187 ))
1188 .expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(
1189 r#"
1190 │ 1 │.........1.........2.... │ 1 │.........1.........2.........+
1191 │ │ │ │3.........4.........5........+
1192 │ │ │ │.6 "#,
1193 );
1194 }
1195
1196 {
1197 config.wrap_configrust-analyzer cargo git-delta 0.19.2 config/Config#wrap_config..max_linesrust-analyzer cargo git-delta 0.19.2 wrapping/WrapConfig#max_lines. = 2;
1198 DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_config().(&config)
1199 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1200 "{HUNK_ALIGN_DIFF_HEADER}-{HUNK_ALIGN_DIFF_SHORT}+{HUNK_ALIGN_DIFF_LONG}",
1201 ))
1202 .expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(
1203 r#"
1204 │ 1 │.........1.........2.... │ 1 │.........1.........2.........+
1205 │ │ │ │3.........4.........5........>"#,
1206 );
1207 }
1208 }
1209 }