| 1 |
use itertoolsrust-analyzer cargo itertools 0.14.0 crate/::Itertoolsrust-analyzer cargo itertools 0.14.0 Itertools#; |
| 2 |
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#; |
| 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/::ansirust-analyzer cargo git-delta 0.19.2 ansi/; |
| 6 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::clirust-analyzer cargo git-delta 0.19.2 cli/; |
| 7 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::configrust-analyzer cargo git-delta 0.19.2 config/::{selfrust-analyzer cargo git-delta 0.19.2 config/, delta_unreachablerust-analyzer cargo git-delta 0.19.2 config/delta_unreachable()., Configrust-analyzer cargo git-delta 0.19.2 config/Config#}; |
| 8 |
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#; |
| 9 |
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#; |
| 10 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::editsrust-analyzer cargo git-delta 0.19.2 edits/; |
| 11 |
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/, OptionValueFunctionrust-analyzer cargo git-delta 0.19.2 features/OptionValueFunction#}; |
| 12 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::minusplusrust-analyzer cargo git-delta 0.19.2 minusplus/::*; |
| 13 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::paintrust-analyzer cargo git-delta 0.19.2 paint/::{BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#, BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#, LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#, Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#}; |
| 14 |
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#; |
| 15 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::wrappingrust-analyzer cargo git-delta 0.19.2 wrapping/::{wrap_minusplus_blockrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_minusplus_block()., wrap_zero_blockrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_zero_block().}; |
| 16 |
|
| 17 |
pub fn make_featurerust-analyzer cargo git-delta 0.19.2 features/side_by_side/make_feature().() -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, OptionValueFunctionrust-analyzer cargo git-delta 0.19.2 features/OptionValueFunction#)> { |
| 18 |
builtin_featurerust-analyzer cargo git-delta 0.19.2 features/builtin_feature!!([ |
| 19 |
( |
| 20 |
"side-by-side", |
| 21 |
bool, |
| 22 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 23 |
_opt => true |
| 24 |
), |
| 25 |
("features", bool, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, _opt => "line-numbers"), |
| 26 |
("line-numbers-left-format", Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, _opt => "│{nm:^4}│".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 27 |
("line-numbers-right-format", Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, _opt => "│{np:^4}│".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 28 |
]) |
| 29 |
} |
| 30 |
|
| 31 |
// Aliases for Minus/Plus because Left/Right and PanelSide makes |
| 32 |
// more sense in a side-by-side context. |
| 33 |
pub use craterust-analyzer cargo git-delta 0.19.2 crate/::minusplusrust-analyzer cargo git-delta 0.19.2 minusplus/::MinusPlusIndexrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex# as PanelSiderust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#; |
| 34 |
pub use MinusPlusIndexrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#::Minusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus# as Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#; |
| 35 |
pub use MinusPlusIndexrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#::Plusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus# as Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#; |
| 36 |
|
| 37 |
use superrust-analyzer cargo git-delta 0.19.2 features/::line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::LineNumbersDatarust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#; |
| 38 |
|
| 39 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 40 |
pub struct Panelrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel# { |
| 41 |
pub widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel#width.: usize, |
| 42 |
} |
| 43 |
|
| 44 |
pub type LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#<T> = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#<T>; |
| 45 |
|
| 46 |
pub type SideBySideDatarust-analyzer cargo git-delta 0.19.2 features/side_by_side/SideBySideData# = LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#<Panelrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel#>; |
| 47 |
|
| 48 |
impl SideBySideDatarust-analyzer cargo git-delta 0.19.2 features/side_by_side/SideBySideData# { |
| 49 |
/// Create a [`LeftRight<Panel>`](LeftRight<Panel>) named [`SideBySideData`]. |
| 50 |
pub fn new_sbsrust-analyzer cargo git-delta 0.19.2 features/side_by_side/impl#[`MinusPlus<Panel>`]new_sbs().(decorations_width: &clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, available_terminal_width: &usize) -> Selfrust-analyzer cargo git-delta 0.19.2 features/side_by_side/impl#[`MinusPlus<Panel>`] { |
| 51 |
let panel_width = match decorations_width { |
| 52 |
clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Fixedrust-analyzer cargo git-delta 0.19.2 cli/Width#Fixed#(w) => w rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Div<usize>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Div<usize>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Div<usize>`]div().2, |
| 53 |
_ => available_terminal_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Div<usize>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Div<usize>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Div<usize>`]div().2, |
| 54 |
}; |
| 55 |
SideBySideDatarust-analyzer cargo git-delta 0.19.2 features/side_by_side/SideBySideData#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().(Panelrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel# { widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel#width.: panel_width }, Panelrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel# { widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel#width.: panel_width }) |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
pub fn available_line_widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/available_line_width().( |
| 60 |
config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 61 |
data: &line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::LineNumbersDatarust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#, |
| 62 |
) -> line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::SideBySideLineWidthrust-analyzer cargo git-delta 0.19.2 features/line_numbers/SideBySideLineWidth# { |
| 63 |
let line_numbers_width = data.formatted_widthrust-analyzer cargo git-delta 0.19.2 features/line_numbers/impl#[`LineNumbersData<'a>`]formatted_width().(); |
| 64 |
|
| 65 |
// The width can be reduced by the line numbers and/or |
| 66 |
// a possibly added/restored 1-wide "+/-/ " prefix. |
| 67 |
let line_width = |side: PanelSiderust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#| { |
| 68 |
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().side]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index(). |
| 69 |
.widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel#width. |
| 70 |
.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(line_numbers_width[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().side]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().) |
| 71 |
.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(config.keep_plus_minus_markersrust-analyzer cargo git-delta 0.19.2 config/Config#keep_plus_minus_markers. as usize) |
| 72 |
}; |
| 73 |
|
| 74 |
LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().(line_width(Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#), line_width(Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#)) |
| 75 |
} |
| 76 |
|
| 77 |
pub fn line_is_too_longrust-analyzer cargo git-delta 0.19.2 features/side_by_side/line_is_too_long().(line: &str, line_width: usize) -> bool { |
| 78 |
debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(line.ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().('\n')); |
| 79 |
|
| 80 |
// graphemes will take care of newlines |
| 81 |
line.widthrust-analyzer cargo unicode-width 0.1.14 impl#[str][UnicodeWidthStr]width().() 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().line_width |
| 82 |
} |
| 83 |
|
| 84 |
/// Return whether any of the input lines is too long, and a data |
| 85 |
/// structure indicating which of the input lines are too long. This avoids |
| 86 |
/// recalculating the length later. |
| 87 |
pub fn has_long_linesrust-analyzer cargo git-delta 0.19.2 features/side_by_side/has_long_lines().( |
| 88 |
lines: &LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#<&Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#)>>, |
| 89 |
line_width: &line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::SideBySideLineWidthrust-analyzer cargo git-delta 0.19.2 features/line_numbers/SideBySideLineWidth#, |
| 90 |
) -> (bool, LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<bool>>) { |
| 91 |
let mut wrap_any = LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#::defaultrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][Default]default().(); |
| 92 |
let mut wrapping_lines = LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#::defaultrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][Default]default().(); |
| 93 |
|
| 94 |
let mut check_if_too_long = |side| { |
| 95 |
let lines_side: &[(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#)] = lines[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().side]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 96 |
wrapping_lines[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut().side]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut(). = lines_side |
| 97 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 98 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(line, _)| line_is_too_longrust-analyzer cargo git-delta 0.19.2 features/side_by_side/line_is_too_long().(line, line_width[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().side]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)) |
| 99 |
.inspectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#inspect().(|b| wrap_any[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut().side]rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitOrAssign<&bool>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitOrAssign<&bool>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitOrAssign<&bool>`]bitor_assign().b) |
| 100 |
.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 101 |
}; |
| 102 |
|
| 103 |
check_if_too_long(Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#); |
| 104 |
check_if_too_long(Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#); |
| 105 |
|
| 106 |
(wrap_any[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(). || wrap_any[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()., wrapping_lines) |
| 107 |
} |
| 108 |
|
| 109 |
#[allow(clippy::too_many_arguments)] |
| 110 |
pub fn paint_minus_and_plus_lines_side_by_siderust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_minus_and_plus_lines_side_by_side().( |
| 111 |
lines: LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#<&Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#)>>, |
| 112 |
syntax_sections: LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>>>, |
| 113 |
diff_sections: LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>>>, |
| 114 |
lines_have_homolog: LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<bool>>, |
| 115 |
line_alignment: 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>)>, |
| 116 |
line_numbers_data: &mut Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LineNumbersDatarust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#>, |
| 117 |
output_buffer: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 118 |
config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 119 |
) { |
| 120 |
let line_states = LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().( |
| 121 |
lines[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()..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().(|(_, state)| state.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 122 |
lines[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(). |
| 123 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 124 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(_, state)| state.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().()) |
| 125 |
.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 126 |
); |
| 127 |
|
| 128 |
let line_numbers_data = line_numbers_data |
| 129 |
.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().() |
| 130 |
.unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| delta_unreachablerust-analyzer cargo git-delta 0.19.2 config/delta_unreachable().("side-by-side requires Some(line_numbers_data)")); |
| 131 |
|
| 132 |
let bg_should_fill = LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().( |
| 133 |
// Using an ANSI sequence to fill the left panel would not work. |
| 134 |
BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#::Withrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#With#(BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#::Spacesrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#Spaces#), |
| 135 |
// Use what is configured for the right side. |
| 136 |
BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#::Withrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#With#(config.line_fill_methodrust-analyzer cargo git-delta 0.19.2 config/Config#line_fill_method.), |
| 137 |
); |
| 138 |
|
| 139 |
// Only set `should_wrap` to true if wrapping is wanted and lines which are |
| 140 |
// too long are found. |
| 141 |
// If so, remember the calculated line width and which of the lines are too |
| 142 |
// long for later re-use. |
| 143 |
let (should_wrap, line_width, long_lines) = { |
| 144 |
if 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. 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 { |
| 145 |
(false, LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#::defaultrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][Default]default().(), LeftRightrust-analyzer cargo git-delta 0.19.2 features/side_by_side/LeftRight#::defaultrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][Default]default().()) |
| 146 |
} else { |
| 147 |
let line_width = available_line_widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/available_line_width().(config, line_numbers_data); |
| 148 |
|
| 149 |
let (should_wrap, long_lines) = has_long_linesrust-analyzer cargo git-delta 0.19.2 features/side_by_side/has_long_lines().(&lines, &line_width); |
| 150 |
|
| 151 |
(should_wrap, line_width, long_lines) |
| 152 |
} |
| 153 |
}; |
| 154 |
|
| 155 |
let (line_alignment, line_states, syntax_sections, diff_sections) = if should_wrap { |
| 156 |
// Calculated for syntect::highlighting::style::Style and delta::Style |
| 157 |
wrap_minusplus_blockrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_minusplus_block().( |
| 158 |
config, |
| 159 |
syntax_sections, |
| 160 |
diff_sections, |
| 161 |
&line_alignment, |
| 162 |
&line_width, |
| 163 |
&long_lines, |
| 164 |
) |
| 165 |
} else { |
| 166 |
(line_alignment, line_states, syntax_sections, diff_sections) |
| 167 |
}; |
| 168 |
let lines_have_homolog = if should_wrap { |
| 169 |
editsrust-analyzer cargo git-delta 0.19.2 edits/::make_lines_have_homologrust-analyzer cargo git-delta 0.19.2 edits/make_lines_have_homolog().(&line_alignment) |
| 170 |
} else { |
| 171 |
lines_have_homolog |
| 172 |
}; |
| 173 |
|
| 174 |
for (minus_line_index, plus_line_index) in line_alignment { |
| 175 |
let left_state = match minus_line_index { |
| 176 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i) => &line_states[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().[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 177 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => &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#), |
| 178 |
}; |
| 179 |
output_buffer.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&paint_left_panel_minus_linerust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_left_panel_minus_line().( |
| 180 |
minus_line_index, |
| 181 |
&syntax_sections[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()., |
| 182 |
&diff_sections[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()., |
| 183 |
&lines_have_homolog[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()., |
| 184 |
left_state, |
| 185 |
&mut Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line_numbers_data), |
| 186 |
bg_should_fill[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()., |
| 187 |
config, |
| 188 |
)); |
| 189 |
|
| 190 |
let right_state = match plus_line_index { |
| 191 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i) => &line_states[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().[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 192 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => &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#), |
| 193 |
}; |
| 194 |
output_buffer.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&paint_right_panel_plus_linerust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_right_panel_plus_line().( |
| 195 |
plus_line_index, |
| 196 |
&syntax_sections[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()., |
| 197 |
&diff_sections[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()., |
| 198 |
&lines_have_homolog[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()., |
| 199 |
right_state, |
| 200 |
&mut Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line_numbers_data), |
| 201 |
bg_should_fill[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()., |
| 202 |
config, |
| 203 |
)); |
| 204 |
output_buffer.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n'); |
| 205 |
|
| 206 |
// HACK: The left line number is not getting incremented in `linenumbers_and_styles()` |
| 207 |
// when the alignment matches a minus with a plus line, so fix that here and take |
| 208 |
// wrapped lines into account. |
| 209 |
// Similarly an increment happens when it should not, so undo that. |
| 210 |
// TODO: Pass this information down into `paint_line()` to set `increment` accordingly. |
| 211 |
match (left_state, right_state, minus_line_index, plus_line_index) { |
| 212 |
(Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinusWrapped#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(_, _), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => { |
| 213 |
line_numbers_data.line_numberrust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#line_number.[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(). = |
| 214 |
line_numbers_data.line_numberrust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#line_number.[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()..saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(1) |
| 215 |
} |
| 216 |
// Duplicating the logic from `linenumbers_and_styles()` a bit: |
| 217 |
(Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinusWrapped# | Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlusWrapped#, _, _, _) => {} |
| 218 |
(_, _, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_)) => line_numbers_data.line_numberrust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#line_number.[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(). 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().1, |
| 219 |
_ => {} |
| 220 |
} |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
#[allow(clippy::too_many_arguments)] |
| 225 |
pub fn paint_zero_lines_side_by_siderust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_zero_lines_side_by_side().<'a>( |
| 226 |
line: &str, |
| 227 |
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#>>, |
| 228 |
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#>>, |
| 229 |
output_buffer: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 230 |
config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 231 |
line_numbers_data: &mut 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#>, |
| •232 |
painted_prefix: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::AnsiStringrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiString#>, |
| 233 |
background_color_extends_to_terminal_width: BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#, |
| 234 |
) { |
| 235 |
let states = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(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#)]; |
| 236 |
|
| 237 |
let (states, syntax_style_sections, diff_style_sections) = wrap_zero_blockrust-analyzer cargo git-delta 0.19.2 wrapping/wrap_zero_block().( |
| 238 |
config, |
| 239 |
line, |
| 240 |
states, |
| 241 |
syntax_style_sections, |
| 242 |
diff_style_sections, |
| 243 |
line_numbers_data, |
| 244 |
); |
| 245 |
|
| 246 |
for (line_index, ((syntax_sections, diff_sections), state)) in syntax_style_sections |
| 247 |
.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 248 |
.zip_eqrust-analyzer cargo itertools 0.14.0 Itertools#zip_eq().(diff_style_sections.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) |
| 249 |
.zip_eqrust-analyzer cargo itertools 0.14.0 Itertools#zip_eq().(states.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()) |
| 250 |
.enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() |
| 251 |
{ |
| 252 |
for panel_side in &[Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#, Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#] { |
| 253 |
let (mut panel_line, panel_line_is_empty) = Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::paint_linerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_line().( |
| 254 |
&syntax_sections, |
| 255 |
diff_sections, |
| 256 |
&state, |
| 257 |
line_numbers_data, |
| 258 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().panel_side), |
| 259 |
painted_prefix.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(), |
| 260 |
config, |
| 261 |
); |
| 262 |
pad_panel_line_to_widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/pad_panel_line_to_width().( |
| 263 |
&mut panel_line, |
| 264 |
panel_line_is_empty, |
| 265 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line_index), |
| 266 |
&diff_style_sections, |
| 267 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 268 |
&state, |
| 269 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().panel_side, |
| 270 |
background_color_extends_to_terminal_width, |
| 271 |
config, |
| 272 |
); |
| 273 |
output_buffer.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&panel_line); |
| 274 |
} |
| 275 |
output_buffer.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n'); |
| 276 |
} |
| 277 |
} |
| 278 |
|
| 279 |
#[allow(clippy::too_many_arguments)] |
| 280 |
fn paint_left_panel_minus_linerust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_left_panel_minus_line().<'a>( |
| 281 |
line_index: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 282 |
syntax_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>], |
| 283 |
diff_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>], |
| 284 |
lines_have_homolog: &[bool], |
| 285 |
state: &'a Staterust-analyzer cargo git-delta 0.19.2 delta/State#, |
| 286 |
line_numbers_data: &mut 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#>, |
| 287 |
background_color_extends_to_terminal_width: BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#, |
| 288 |
config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 289 |
) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 290 |
let (mut panel_line, panel_line_is_empty) = paint_minus_or_plus_panel_linerust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_minus_or_plus_panel_line().( |
| 291 |
line_index, |
| 292 |
syntax_style_sections, |
| 293 |
diff_style_sections, |
| 294 |
state, |
| 295 |
line_numbers_data, |
| 296 |
Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#, |
| 297 |
config, |
| 298 |
); |
| 299 |
pad_panel_line_to_widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/pad_panel_line_to_width().( |
| 300 |
&mut panel_line, |
| 301 |
panel_line_is_empty, |
| 302 |
line_index, |
| 303 |
diff_style_sections, |
| 304 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(lines_have_homolog), |
| 305 |
state, |
| 306 |
Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#, |
| 307 |
background_color_extends_to_terminal_width, |
| 308 |
config, |
| 309 |
); |
| 310 |
|
| 311 |
panel_line |
| 312 |
} |
| 313 |
|
| 314 |
#[allow(clippy::too_many_arguments)] |
| 315 |
fn paint_right_panel_plus_linerust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_right_panel_plus_line().<'a>( |
| 316 |
line_index: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 317 |
syntax_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>], |
| 318 |
diff_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>], |
| 319 |
lines_have_homolog: &[bool], |
| 320 |
state: &'a Staterust-analyzer cargo git-delta 0.19.2 delta/State#, |
| 321 |
line_numbers_data: &mut 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#>, |
| 322 |
background_color_extends_to_terminal_width: BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#, |
| 323 |
config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 324 |
) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 325 |
let (mut panel_line, panel_line_is_empty) = paint_minus_or_plus_panel_linerust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_minus_or_plus_panel_line().( |
| 326 |
line_index, |
| 327 |
syntax_style_sections, |
| 328 |
diff_style_sections, |
| 329 |
state, |
| 330 |
line_numbers_data, |
| 331 |
Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#, |
| 332 |
config, |
| 333 |
); |
| 334 |
|
| 335 |
pad_panel_line_to_widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/pad_panel_line_to_width().( |
| 336 |
&mut panel_line, |
| 337 |
panel_line_is_empty, |
| 338 |
line_index, |
| 339 |
diff_style_sections, |
| 340 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(lines_have_homolog), |
| 341 |
state, |
| 342 |
Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#, |
| 343 |
background_color_extends_to_terminal_width, |
| 344 |
config, |
| 345 |
); |
| 346 |
|
| 347 |
panel_line |
| 348 |
} |
| 349 |
|
| 350 |
#[allow(clippy::too_many_arguments)] |
| 351 |
fn get_right_fill_style_for_panelrust-analyzer cargo git-delta 0.19.2 features/side_by_side/get_right_fill_style_for_panel().( |
| 352 |
line_is_empty: bool, |
| 353 |
line_index: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 354 |
diff_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'_, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>], |
| 355 |
lines_have_homolog: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&[bool]>, |
| 356 |
state: &Staterust-analyzer cargo git-delta 0.19.2 delta/State#, |
| 357 |
panel_side: PanelSiderust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#, |
| 358 |
background_color_extends_to_terminal_width: BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#, |
| 359 |
config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 360 |
) -> (Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#>, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#) { |
| 361 |
// If in the left panel then it must be filled with spaces. |
| 362 |
let none_or_override = if panel_side rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[MinusPlusIndex][`PartialEq<Self>`]eq().==rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[MinusPlusIndex][`PartialEq<Self>`]eq(). rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[MinusPlusIndex][`PartialEq<Self>`]eq().Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus# { |
| 363 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#::Spacesrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#Spaces#) |
| 364 |
} else { |
| 365 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 366 |
}; |
| 367 |
|
| 368 |
match (line_is_empty, line_index) { |
| 369 |
(true, _) => (none_or_override, config.null_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_style.), |
| 370 |
(false, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => (none_or_override, config.null_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_style.), |
| 371 |
(false, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(index)) => { |
| 372 |
let (bg_fill_mode, fill_style) = |
| 373 |
Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::get_should_right_fill_background_color_and_fill_stylerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]get_should_right_fill_background_color_and_fill_style().( |
| 374 |
&diff_style_sections[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., |
| 375 |
lines_have_homolog.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|h| h[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().), |
| 376 |
state, |
| 377 |
background_color_extends_to_terminal_width, |
| 378 |
config, |
| 379 |
); |
| 380 |
|
| 381 |
match bg_fill_mode { |
| 382 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => (none_or_override, config.null_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_style.), |
| 383 |
_ if panel_side rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[MinusPlusIndex][`PartialEq<Self>`]eq().==rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[MinusPlusIndex][`PartialEq<Self>`]eq(). rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[MinusPlusIndex][`PartialEq<Self>`]eq().Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus# => (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#::Spacesrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#Spaces#), fill_style), |
| 384 |
_ => (bg_fill_mode, fill_style), |
| 385 |
} |
| 386 |
} |
| 387 |
} |
| 388 |
} |
| 389 |
|
| 390 |
/// Construct half of a minus or plus line under side-by-side mode, i.e. the half line that |
| 391 |
/// goes in one or other panel. Return a tuple `(painted_half_line, is_empty)`. |
| 392 |
// Suppose the line being displayed is a minus line with a paired plus line. Then both times |
| 393 |
// this function is called, `line_index` will be `Some`. This case proceeds as one would |
| 394 |
// expect: on the first call, we are constructing the left panel line, and we are passed |
| 395 |
// `(Some(index), HunkMinus, Left)`. We pass `(HunkMinus, Left)` to |
| 396 |
// `paint_line`. This has two consequences: |
| 397 |
// 1. `format_and_paint_line_numbers` will increment the minus line number. |
| 398 |
// 2. `format_and_paint_line_numbers` will emit the left line number field, and not the right. |
| 399 |
// |
| 400 |
// The second call does the analogous thing for the plus line to be displayed in the right panel: |
| 401 |
// we are passed `(Some(index), HunkPlus, Right)` and we pass `(HunkPlus, Right)` to `paint_line`, |
| 402 |
// causing it to increment the plus line number and emit the right line number field. |
| 403 |
// |
| 404 |
// Now consider the case where the line being displayed is a minus line with no paired plus line. |
| 405 |
// The first call is as before. On the second call, we are passed `(None, HunkPlus, Right)` and we |
| 406 |
// wish to display the right panel, with its line number container, but without any line number |
| 407 |
// (and without any line contents). We do this by passing (HunkMinus, Right) to `paint_line`, since |
| 408 |
// what this will do is set the line number pair in that function to `(Some(minus_number), None)`, |
| 409 |
// and then only emit the right field (which has a None number, i.e. blank). |
| 410 |
#[allow(clippy::too_many_arguments)] |
| 411 |
fn paint_minus_or_plus_panel_linerust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_minus_or_plus_panel_line().<'a>( |
| 412 |
line_index: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 413 |
syntax_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>], |
| 414 |
diff_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>], |
| 415 |
state: &Staterust-analyzer cargo git-delta 0.19.2 delta/State#, |
| 416 |
line_numbers_data: &mut 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#>, |
| 417 |
panel_side: PanelSiderust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#, |
| 418 |
config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 419 |
) -> (Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, bool) { |
| 420 |
let (empty_line_syntax_sections, empty_line_diff_sections) = (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().(), 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().()); |
| 421 |
|
| 422 |
let (line_syntax_sections, line_diff_sections, state_for_line_numbers_field) = |
| 423 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(index) = line_index { |
| 424 |
( |
| 425 |
&syntax_style_sections[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., |
| 426 |
&diff_style_sections[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., |
| 427 |
state.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().(), |
| 428 |
) |
| 429 |
} else { |
| 430 |
let opposite_state = match state { |
| 431 |
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#, s) => { |
| 432 |
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#, s.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().()) |
| 433 |
} |
| 434 |
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#, s) => { |
| 435 |
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#, s.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().()) |
| 436 |
} |
| 437 |
_ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 438 |
}; |
| 439 |
( |
| 440 |
&empty_line_syntax_sections, |
| 441 |
&empty_line_diff_sections, |
| 442 |
opposite_state, |
| 443 |
) |
| 444 |
}; |
| 445 |
|
| 446 |
let painted_prefix = match (config.keep_plus_minus_markersrust-analyzer cargo git-delta 0.19.2 config/Config#keep_plus_minus_markers., panel_side, state) { |
| 447 |
(true, _, Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlusWrapped#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.plus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_style..paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(" ")), |
| 448 |
(true, _, Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinusWrapped#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.minus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_style..paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(" ")), |
| 449 |
(true, Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#, _) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.minus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_style..paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().("-")), |
| 450 |
(true, Rightrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Plus#, _) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.plus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_style..paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().("+")), |
| 451 |
_ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 452 |
}; |
| 453 |
|
| 454 |
let (line, line_is_empty) = Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::paint_linerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_line().( |
| 455 |
line_syntax_sections, |
| 456 |
line_diff_sections, |
| 457 |
&state_for_line_numbers_field, |
| 458 |
line_numbers_data, |
| 459 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(panel_side), |
| 460 |
painted_prefix, |
| 461 |
config, |
| 462 |
); |
| 463 |
|
| 464 |
(line, line_is_empty) |
| 465 |
} |
| 466 |
|
| 467 |
/// Right-fill the background color of a line in a panel. If in the left panel this is always |
| 468 |
/// done with spaces. The right panel can be filled with spaces or using ANSI sequences |
| 469 |
/// instructing the terminal emulator to fill the background color rightwards. |
| 470 |
#[allow(clippy::too_many_arguments, clippy::comparison_chain)] |
| 471 |
fn pad_panel_line_to_widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/pad_panel_line_to_width().( |
| 472 |
panel_line: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 473 |
panel_line_is_empty: bool, |
| 474 |
line_index: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 475 |
diff_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'_, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>], |
| 476 |
lines_have_homolog: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&[bool]>, |
| 477 |
state: &Staterust-analyzer cargo git-delta 0.19.2 delta/State#, |
| 478 |
panel_side: PanelSiderust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#, |
| 479 |
background_color_extends_to_terminal_width: BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#, |
| 480 |
config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 481 |
) { |
| 482 |
// Emit empty line marker if the panel line is empty but not empty-by-construction. IOW if the |
| 483 |
// other panel contains a real line, and we are currently emitting an empty counterpart panel |
| 484 |
// to form the other half of the line, then don't emit the empty line marker. |
| 485 |
if panel_line_is_empty && line_index.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 486 |
match state { |
| 487 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(_, _) => Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::mark_empty_linerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]mark_empty_line().( |
| 488 |
&config.minus_empty_line_marker_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_empty_line_marker_style., |
| 489 |
panel_line, |
| 490 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(" "), |
| 491 |
), |
| 492 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(_, _) => Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::mark_empty_linerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]mark_empty_line().( |
| 493 |
&config.plus_empty_line_marker_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_empty_line_marker_style., |
| 494 |
panel_line, |
| 495 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(" "), |
| 496 |
), |
| 497 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(_, _) => {} |
| 498 |
_ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 499 |
}; |
| 500 |
}; |
| 501 |
|
| 502 |
let text_width = ansirust-analyzer cargo git-delta 0.19.2 ansi/::measure_text_widthrust-analyzer cargo git-delta 0.19.2 ansi/measure_text_width().(panel_line); |
| 503 |
let panel_width = 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().panel_side]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.; |
| 504 |
|
| 505 |
if text_width 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().panel_width { |
| 506 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().panel_line = |
| 507 |
ansirust-analyzer cargo git-delta 0.19.2 ansi/::truncate_strrust-analyzer cargo git-delta 0.19.2 ansi/truncate_str().(panel_line, panel_width, &config.truncation_symbolrust-analyzer cargo git-delta 0.19.2 config/Config#truncation_symbol.).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 508 |
} |
| 509 |
|
| 510 |
let (bg_fill_mode, fill_style) = get_right_fill_style_for_panelrust-analyzer cargo git-delta 0.19.2 features/side_by_side/get_right_fill_style_for_panel().( |
| 511 |
panel_line_is_empty, |
| 512 |
line_index, |
| 513 |
diff_style_sections, |
| 514 |
lines_have_homolog, |
| 515 |
state, |
| 516 |
panel_side, |
| 517 |
background_color_extends_to_terminal_width, |
| 518 |
config, |
| 519 |
); |
| 520 |
|
| 521 |
match bg_fill_mode { |
| 522 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#::TryAnsiSequencerust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#TryAnsiSequence#) => { |
| 523 |
Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::right_fill_background_colorrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]right_fill_background_color().(panel_line, fill_style) |
| 524 |
} |
| 525 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#::Spacesrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#Spaces#) if text_width 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().panel_width => (), |
| 526 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#::Spacesrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#Spaces#) => panel_line.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().( |
| 527 |
#[allow(clippy::unnecessary_to_owned)] |
| 528 |
&fill_style |
| 529 |
.paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(" ".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(panel_width 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().text_width)) |
| 530 |
.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 531 |
), |
| 532 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => (), |
| 533 |
} |
| 534 |
} |
| 535 |
|
| 536 |
pub mod ansifillrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/ { |
| 537 |
use superrust-analyzer cargo git-delta 0.19.2 features/side_by_side/::SideBySideDatarust-analyzer cargo git-delta 0.19.2 features/side_by_side/SideBySideData#; |
| 538 |
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#; |
| 539 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::paintrust-analyzer cargo git-delta 0.19.2 paint/::BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#; |
| 540 |
|
| 541 |
pub const ODD_PAD_CHARrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/ODD_PAD_CHAR.: char = ' '; |
| 542 |
|
| 543 |
// Panels in side-by-side mode always sum up to an even number, so when the terminal |
| 544 |
// has an odd width an extra column is left over. |
| 545 |
// If the background color is extended with an ANSI sequence (which only knows "fill |
| 546 |
// this row until the end") instead of spaces (see `BgFillMethod`), then the coloring |
| 547 |
// extends into that column. This becomes noticeable when the displayed content reaches |
| 548 |
// the right side of the right panel to be truncated or wrapped. |
| 549 |
// However using an ANSI sequence instead of spaces is generally preferable because |
| 550 |
// small changes to the terminal width are less noticeable. |
| 551 |
|
| 552 |
/// The solution in this case is to add `ODD_PAD_CHAR` before the first line number in |
| 553 |
/// the right panel and increasing its width by one, thus using the full terminal width |
| 554 |
/// with the two panels. |
| 555 |
/// This also means line numbers can not be disabled in side-by-side mode, but they may |
| 556 |
/// not actually paint numbers. |
| 557 |
#[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:)] |
| 558 |
pub struct UseFullPanelWidthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/UseFullPanelWidth#(pub bool); |
| 559 |
impl UseFullPanelWidthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/UseFullPanelWidth# { |
| 560 |
pub fn newrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]new().(config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#) -> Selfrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth] { |
| 561 |
Selfrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]( |
| 562 |
config.side_by_siderust-analyzer cargo git-delta 0.19.2 config/Config#side_by_side. |
| 563 |
&& Selfrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]::is_odd_with_ansirust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]is_odd_with_ansi().(&config.decorations_widthrust-analyzer cargo git-delta 0.19.2 config/Config#decorations_width., &config.line_fill_methodrust-analyzer cargo git-delta 0.19.2 config/Config#line_fill_method.), |
| 564 |
) |
| 565 |
} |
| 566 |
pub fn sbs_odd_fixrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]sbs_odd_fix().( |
| 567 |
width: &craterust-analyzer cargo git-delta 0.19.2 crate/::clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, |
| 568 |
method: &BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#, |
| 569 |
sbs_data: SideBySideDatarust-analyzer cargo git-delta 0.19.2 features/side_by_side/SideBySideData#, |
| 570 |
) -> SideBySideDatarust-analyzer cargo git-delta 0.19.2 features/side_by_side/SideBySideData# { |
| 571 |
if Selfrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]::is_odd_with_ansirust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]is_odd_with_ansi().(width, method) { |
| 572 |
Selfrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]::adapt_sbs_datarust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]adapt_sbs_data().(sbs_data) |
| 573 |
} else { |
| 574 |
sbs_data |
| 575 |
} |
| 576 |
} |
| 577 |
pub fn pad_widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]pad_width().(&self) -> bool { |
| 578 |
self.0rust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/UseFullPanelWidth#0. |
| 579 |
} |
| 580 |
fn is_odd_with_ansirust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]is_odd_with_ansi().(width: &craterust-analyzer cargo git-delta 0.19.2 crate/::clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, method: &BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#) -> bool { |
| 581 |
method 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().&BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#::TryAnsiSequencerust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#TryAnsiSequence# |
| 582 |
&& matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(&width, craterust-analyzer cargo git-delta 0.19.2 crate/::clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Fixedrust-analyzer cargo git-delta 0.19.2 cli/Width#Fixed#(width) if width %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Rem<usize>`]rem(). 2 == 1) |
| 583 |
} |
| 584 |
fn adapt_sbs_datarust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]adapt_sbs_data().(mut sbs_data: SideBySideDatarust-analyzer cargo git-delta 0.19.2 features/side_by_side/SideBySideData#) -> SideBySideDatarust-analyzer cargo git-delta 0.19.2 features/side_by_side/SideBySideData# { |
| 585 |
sbs_data[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut().superrust-analyzer cargo git-delta 0.19.2 features/side_by_side/::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()..widthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/Panel#width. 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().1; |
| 586 |
sbs_data |
| 587 |
} |
| 588 |
} |
| 589 |
} |
| 590 |
|
| 591 |
#[cfg(test)] |
| 592 |
pub mod testsrust-analyzer cargo git-delta 0.19.2 features/side_by_side/tests/ { |
| 593 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::ansirust-analyzer cargo git-delta 0.19.2 ansi/::strip_ansi_codesrust-analyzer cargo git-delta 0.19.2 ansi/strip_ansi_codes().; |
| 594 |
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/::testsrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/::*; |
| 595 |
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()., run_deltarust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/run_delta()., DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#}; |
| 596 |
use instarust-analyzer cargo insta 1.39.0 crate/::assert_snapshotrust-analyzer cargo insta 1.39.0 macros/assert_snapshot!; |
| 597 |
|
| 598 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 599 |
fn test_two_fitting_minus_linesrust-analyzer cargo git-delta 0.19.2 features/side_by_side/tests/test_two_fitting_minus_lines().() { |
| 600 |
// rustfmt ignores the assert macro arguments, so do the setup outside |
| 601 |
let result = 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().(&["--side-by-side"]) |
| 602 |
.with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(TWO_MINUS_LINES_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_MINUS_LINES_DIFF.) |
| 603 |
.skip_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]skip_header().(); |
| 604 |
assert_snapshotrust-analyzer cargo insta 1.39.0 macros/assert_snapshot!!(result, @r###" |
| 605 |
│ 1 │a = 1 │ │ |
| 606 |
│ 2 │b = 23456 │ │ |
| 607 |
"### |
| 608 |
); |
| 609 |
} |
| 610 |
|
| 611 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 612 |
fn test_two_minus_lines_truncatedrust-analyzer cargo git-delta 0.19.2 features/side_by_side/tests/test_two_minus_lines_truncated().() { |
| 613 |
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().(&[ |
| 614 |
"--side-by-side", |
| 615 |
"--wrap-max-lines", |
| 616 |
"0", |
| 617 |
"--width", |
| 618 |
"28", |
| 619 |
"--line-fill-method=spaces", |
| 620 |
]) |
| 621 |
.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().()) |
| 622 |
.with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(TWO_MINUS_LINES_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_MINUS_LINES_DIFF.) |
| 623 |
.expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().( |
| 624 |
r#" |
| 625 |
│ 1 │a = 1 │ │ |
| 626 |
│ 2 │b = 234>│ │"#, |
| 627 |
); |
| 628 |
} |
| 629 |
|
| 630 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 631 |
fn test_two_plus_linesrust-analyzer cargo git-delta 0.19.2 features/side_by_side/tests/test_two_plus_lines().() { |
| 632 |
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().(&[ |
| 633 |
"--side-by-side", |
| 634 |
"--width", |
| 635 |
"41", |
| 636 |
"--line-fill-method=spaces", |
| 637 |
]) |
| 638 |
.with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(TWO_PLUS_LINES_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_PLUS_LINES_DIFF.) |
| 639 |
.expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().( |
| 640 |
r#" |
| 641 |
│ │ │ 1 │a = 1 |
| 642 |
│ │ │ 2 │b = 234567 "#, |
| 643 |
); |
| 644 |
} |
| 645 |
|
| 646 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 647 |
fn test_two_plus_lines_spaces_and_ansirust-analyzer cargo git-delta 0.19.2 features/side_by_side/tests/test_two_plus_lines_spaces_and_ansi().() { |
| 648 |
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().(&[ |
| 649 |
"--side-by-side", |
| 650 |
"--width", |
| 651 |
"41", |
| 652 |
"--line-fill-method=spaces", |
| 653 |
]) |
| 654 |
.explain_ansirust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]explain_ansi().() |
| 655 |
.with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(TWO_PLUS_LINES_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_PLUS_LINES_DIFF.) |
| 656 |
.expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(r#" |
| 657 |
(blue)│(88) (blue)│(normal) (blue)│(28) 1 (blue)│(231 22)a (203)=(231) (141)1(normal 22) (normal) |
| 658 |
(blue)│(88) (blue)│(normal) (blue)│(28) 2 (blue)│(231 22)b (203)=(231) (141)234567(normal 22) (normal)"#); |
| 659 |
|
| 660 |
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().(&[ |
| 661 |
"--side-by-side", |
| 662 |
"--width", |
| 663 |
"41", |
| 664 |
"--line-fill-method=ansi", |
| 665 |
]) |
| 666 |
.explain_ansirust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]explain_ansi().() |
| 667 |
.with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(TWO_PLUS_LINES_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_PLUS_LINES_DIFF.) |
| 668 |
.expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().(r#" |
| 669 |
(blue)│(88) (blue)│(normal) (blue) │(28) 1 (blue)│(231 22)a (203)=(231) (141)1(normal) |
| 670 |
(blue)│(88) (blue)│(normal) (blue) │(28) 2 (blue)│(231 22)b (203)=(231) (141)234567(normal)"#); |
| 671 |
} |
| 672 |
|
| 673 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 674 |
fn test_two_plus_lines_truncatedrust-analyzer cargo git-delta 0.19.2 features/side_by_side/tests/test_two_plus_lines_truncated().() { |
| 675 |
let mut config = make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&[ |
| 676 |
"--side-by-side", |
| 677 |
"--wrap-max-lines", |
| 678 |
"0", |
| 679 |
"--width", |
| 680 |
"30", |
| 681 |
"--line-fill-method=spaces", |
| 682 |
]); |
| 683 |
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().(); |
| 684 |
|
| 685 |
let output = run_deltarust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/run_delta().(TWO_PLUS_LINES_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_PLUS_LINES_DIFF., &config); |
| 686 |
let mut lines = 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.); |
| 687 |
let (line_1, line_2) = (lines.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/skip/impl#[`Skip<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), lines.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/skip/impl#[`Skip<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 688 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("│ │ │ 1 │a = 1 ", strip_ansi_codesrust-analyzer cargo git-delta 0.19.2 ansi/strip_ansi_codes().(line_1)); |
| 689 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("│ │ │ 2 │b = 2345>", strip_ansi_codesrust-analyzer cargo git-delta 0.19.2 ansi/strip_ansi_codes().(line_2)); |
| 690 |
} |
| 691 |
|
| 692 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 693 |
fn test_two_plus_lines_exact_fitrust-analyzer cargo git-delta 0.19.2 features/side_by_side/tests/test_two_plus_lines_exact_fit().() { |
| 694 |
let config = |
| 695 |
make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&["--side-by-side", "--width", "33", "--line-fill-method=ansi"]); |
| 696 |
let output = run_deltarust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/run_delta().(TWO_PLUS_LINES_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_PLUS_LINES_DIFF., &config); |
| 697 |
let mut lines = 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.); |
| 698 |
let (line_1, line_2) = (lines.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/skip/impl#[`Skip<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), lines.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/skip/impl#[`Skip<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 699 |
let sac = strip_ansi_codesrust-analyzer cargo git-delta 0.19.2 ansi/strip_ansi_codes().; // alias to help with `cargo fmt`-ing: |
| 700 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("│ │ │ 1 │a = 1", sac(line_1)); |
| 701 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("│ │ │ 2 │b = 234567", sac(line_2)); |
| 702 |
} |
| 703 |
|
| 704 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 705 |
fn test_one_minus_one_plus_linerust-analyzer cargo git-delta 0.19.2 features/side_by_side/tests/test_one_minus_one_plus_line().() { |
| 706 |
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().(&[ |
| 707 |
"--side-by-side", |
| 708 |
"--width", |
| 709 |
"40", |
| 710 |
"--line-fill-method=spaces", |
| 711 |
]) |
| 712 |
.with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(ONE_MINUS_ONE_PLUS_LINE_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/ONE_MINUS_ONE_PLUS_LINE_DIFF.) |
| 713 |
.expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().( |
| 714 |
r#" |
| 715 |
│ 1 │a = 1 │ 1 │a = 1 |
| 716 |
│ 2 │b = 2 │ 2 │bb = 2 "#, |
| 717 |
); |
| 718 |
} |
| 719 |
|
| 720 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 721 |
fn test_two_minus_lines_unicode_truncatedrust-analyzer cargo git-delta 0.19.2 features/side_by_side/tests/test_two_minus_lines_unicode_truncated().() { |
| 722 |
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().(&[ |
| 723 |
"--side-by-side", |
| 724 |
"--wrap-max-lines", |
| 725 |
"2", |
| 726 |
"--width", |
| 727 |
"16", |
| 728 |
"--line-fill-method=spaces", |
| 729 |
]) |
| 730 |
.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().()) |
| 731 |
.with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(TWO_MINUS_LINES_UNICODE_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_MINUS_LINES_UNICODE_DIFF.) |
| 732 |
.expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().( |
| 733 |
r#" |
| 734 |
│ 1 │↵ │ │ |
| 735 |
│ │↵ │ │ |
| 736 |
│ │ >│ │"#, |
| 737 |
); |
| 738 |
|
| 739 |
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().(&[ |
| 740 |
"--side-by-side", |
| 741 |
"--wrap-max-lines", |
| 742 |
"2", |
| 743 |
"--width", |
| 744 |
"17", |
| 745 |
"--line-fill-method=spaces", |
| 746 |
]) |
| 747 |
.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().()) |
| 748 |
.with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(TWO_MINUS_LINES_UNICODE_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_MINUS_LINES_UNICODE_DIFF.) |
| 749 |
.expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().( |
| 750 |
r#" |
| 751 |
│ 1 │↵ │ │ |
| 752 |
│ │↵ │ │ |
| 753 |
│ │ >│ │"#, |
| 754 |
); |
| 755 |
|
| 756 |
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().(&[ |
| 757 |
"--side-by-side", |
| 758 |
"--wrap-max-lines", |
| 759 |
"2", |
| 760 |
"--width", |
| 761 |
"18", |
| 762 |
"--line-fill-method=spaces", |
| 763 |
]) |
| 764 |
.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().()) |
| 765 |
.with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(TWO_MINUS_LINES_UNICODE_DIFFrust-analyzer cargo git-delta 0.19.2 features/line_numbers/tests/TWO_MINUS_LINES_UNICODE_DIFF.) |
| 766 |
.expect_after_headerrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_after_header().( |
| 767 |
r#" |
| 768 |
│ 1 │一↵│ │ |
| 769 |
│ │二↵│ │ |
| 770 |
│ │三 │ │"#, |
| 771 |
); |
| 772 |
} |
| 773 |
} |