| 1 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 2 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#; |
| 3 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#; |
| 4 |
|
| •5 |
use ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::AnsiStringrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiString#; |
| 6 |
use itertoolsrust-analyzer cargo itertools 0.14.0 crate/::Itertoolsrust-analyzer cargo itertools 0.14.0 Itertools#; |
| 7 |
use syntectrust-analyzer cargo syntect 5.3.0 crate/::easyrust-analyzer cargo syntect 5.3.0 easy/::HighlightLinesrust-analyzer cargo syntect 5.3.0 easy/HighlightLines#; |
| 8 |
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#; |
| 9 |
use syntectrust-analyzer cargo syntect 5.3.0 crate/::parsingrust-analyzer cargo syntect 5.3.0 parsing/::{SyntaxReferencerust-analyzer cargo syntect 5.3.0 parsing/syntax_set/SyntaxReference#, SyntaxSetrust-analyzer cargo syntect 5.3.0 parsing/syntax_set/SyntaxSet#}; |
| 10 |
|
| 11 |
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#}; |
| 12 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::deltarust-analyzer cargo git-delta 0.19.2 delta/::{DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#, InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#, MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#}; |
| 13 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::featuresrust-analyzer cargo git-delta 0.19.2 features/::hyperlinksrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/; |
| 14 |
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/, LineNumbersDatarust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#}; |
| 15 |
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/; |
| 16 |
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/::{selfrust-analyzer cargo git-delta 0.19.2 features/side_by_side/, PanelSiderust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#}; |
| 17 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::handlersrust-analyzer cargo git-delta 0.19.2 handlers/::merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/; |
| 18 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::minusplusrust-analyzer cargo git-delta 0.19.2 minusplus/::*; |
| 19 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::paintrust-analyzer cargo git-delta 0.19.2 paint/::superimpose_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/::superimpose_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/superimpose_style_sections().; |
| 20 |
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#; |
| 21 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::{ansirust-analyzer cargo git-delta 0.19.2 ansi/, stylerust-analyzer cargo git-delta 0.19.2 style/}; |
| 22 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::{editsrust-analyzer cargo git-delta 0.19.2 edits/, utilsrust-analyzer cargo git-delta 0.19.2 utils/, utilsrust-analyzer cargo git-delta 0.19.2 utils/::tabsrust-analyzer cargo git-delta 0.19.2 utils/tabs/}; |
| 23 |
|
| 24 |
pub type LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, S> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(S, &'a str)>; |
| 25 |
|
| 26 |
pub struct Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#<'p> { |
| 27 |
pub minus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#minus_lines.: 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#)>, |
| 28 |
pub plus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#plus_lines.: 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#)>, |
| 29 |
pub writerrust-analyzer cargo git-delta 0.19.2 paint/Painter#writer.: &'p mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 30 |
pub syntaxrust-analyzer cargo git-delta 0.19.2 paint/Painter#syntax.: &'p SyntaxReferencerust-analyzer cargo syntect 5.3.0 parsing/syntax_set/SyntaxReference#, |
| 31 |
pub highlighterrust-analyzer cargo git-delta 0.19.2 paint/Painter#highlighter.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<HighlightLinesrust-analyzer cargo syntect 5.3.0 easy/HighlightLines#<'p>>, |
| 32 |
pub configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config.: &'p configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 33 |
pub output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 34 |
// If config.line_numbers is true, then the following is always Some(). |
| 35 |
// In side-by-side mode it is always Some (but possibly an empty one), even |
| 36 |
// if config.line_numbers is false. See `UseFullPanelWidth` as well. |
| 37 |
pub line_numbers_datarust-analyzer cargo git-delta 0.19.2 paint/Painter#line_numbers_data.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::LineNumbersDatarust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#<'p>>, |
| 38 |
pub merge_conflict_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_lines.: merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/::MergeConflictLinesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictLines#, |
| 39 |
pub merge_conflict_commit_namesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_commit_names.: merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/::MergeConflictCommitNamesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommitNames#, |
| 40 |
} |
| 41 |
|
| 42 |
// How the background of a line is filled up to the end |
| 43 |
#[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 44 |
pub enum BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod# { |
| 45 |
// Fill the background with ANSI spaces if possible, |
| 46 |
// but might fallback to Spaces (e.g. in the left side-by-side panel), |
| 47 |
// also see `UseFullPanelWidth` |
| 48 |
TryAnsiSequencerust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#TryAnsiSequence#, |
| 49 |
Spacesrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#Spaces#, |
| 50 |
} |
| 51 |
|
| 52 |
// If the background of a line extends to the end, and if configured to do so, how. |
| 53 |
#[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 54 |
pub enum BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill# { |
| 55 |
Withrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#With#(BgFillMethodrust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#), |
| 56 |
Norust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#No#, |
| 57 |
} |
| 58 |
|
| 59 |
impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill# { |
| 60 |
fn defaultrust-analyzer cargo git-delta 0.19.2 paint/impl#[BgShouldFill][Default]default().() -> Selfrust-analyzer cargo git-delta 0.19.2 paint/impl#[BgShouldFill][Default] { |
| 61 |
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#::TryAnsiSequencerust-analyzer cargo git-delta 0.19.2 paint/BgFillMethod#TryAnsiSequence#) |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
#[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 66 |
pub enum StyleSectionSpecifierrust-analyzer cargo git-delta 0.19.2 paint/StyleSectionSpecifier#<'l> { |
| 67 |
Stylerust-analyzer cargo git-delta 0.19.2 paint/StyleSectionSpecifier#Style#(Stylerust-analyzer cargo git-delta 0.19.2 style/Style#), |
| 68 |
StyleSectionsrust-analyzer cargo git-delta 0.19.2 paint/StyleSectionSpecifier#StyleSections#(LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'l, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>), |
| 69 |
} |
| 70 |
|
| 71 |
impl<'p> Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#<'p> { |
| 72 |
pub fn newrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]new().(writer: &'p mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, config: &'p configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#) -> Selfrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`] { |
| 73 |
let default_syntax = Selfrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]::get_syntaxrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]get_syntax().(&config.syntax_setrust-analyzer cargo git-delta 0.19.2 config/Config#syntax_set., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &config.default_languagerust-analyzer cargo git-delta 0.19.2 config/Config#default_language.); |
| 74 |
let panel_width_fix = ansifillrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/::UseFullPanelWidthrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/UseFullPanelWidth#::newrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/impl#[UseFullPanelWidth]new().(config); |
| 75 |
|
| 76 |
let line_numbers_data = if config.line_numbersrust-analyzer cargo git-delta 0.19.2 config/Config#line_numbers. { |
| 77 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::LineNumbersDatarust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#::from_format_stringsrust-analyzer cargo git-delta 0.19.2 features/line_numbers/impl#[`LineNumbersData<'a>`]from_format_strings().( |
| 78 |
&config.line_numbers_formatrust-analyzer cargo git-delta 0.19.2 config/Config#line_numbers_format., |
| 79 |
panel_width_fix, |
| 80 |
)) |
| 81 |
} else if config.side_by_siderust-analyzer cargo git-delta 0.19.2 config/Config#side_by_side. { |
| 82 |
// If line numbers are disabled in side-by-side then the data is still used |
| 83 |
// for width calculation and to pad odd width to even, see `UseFullPanelWidth` |
| 84 |
// for details. |
| 85 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::LineNumbersDatarust-analyzer cargo git-delta 0.19.2 features/line_numbers/LineNumbersData#::empty_for_sbsrust-analyzer cargo git-delta 0.19.2 features/line_numbers/impl#[`LineNumbersData<'a>`]empty_for_sbs().( |
| 86 |
panel_width_fix, |
| 87 |
)) |
| 88 |
} else { |
| 89 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 90 |
}; |
| 91 |
Selfrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`] { |
| 92 |
minus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#minus_lines.: 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().(), |
| 93 |
plus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#plus_lines.: 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().(), |
| 94 |
output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(), |
| 95 |
syntaxrust-analyzer cargo git-delta 0.19.2 paint/Painter#syntax.: default_syntax, |
| 96 |
highlighterrust-analyzer cargo git-delta 0.19.2 paint/Painter#highlighter.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 97 |
writerrust-analyzer cargo git-delta 0.19.2 paint/Painter#writer., |
| 98 |
configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config., |
| 99 |
line_numbers_datarust-analyzer cargo git-delta 0.19.2 paint/Painter#line_numbers_data., |
| 100 |
merge_conflict_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_lines.: merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/::MergeConflictLinesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictLines#::newrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Vec<(String, State)>>`]new().(), |
| 101 |
merge_conflict_commit_namesrust-analyzer cargo git-delta 0.19.2 paint/Painter#merge_conflict_commit_names.: merge_conflictrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/::MergeConflictCommitNamesrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/MergeConflictCommitNames#::newrust-analyzer cargo git-delta 0.19.2 handlers/merge_conflict/impl#[`MergeConflictCommits<Option<String>>`]new().(), |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
pub fn set_syntaxrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]set_syntax().(&mut self, filename: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) { |
| 106 |
self.syntaxrust-analyzer cargo git-delta 0.19.2 paint/Painter#syntax. = Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::get_syntaxrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]get_syntax().( |
| 107 |
&self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config..syntax_setrust-analyzer cargo git-delta 0.19.2 config/Config#syntax_set., |
| 108 |
filename, |
| 109 |
&self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config..default_languagerust-analyzer cargo git-delta 0.19.2 config/Config#default_language., |
| 110 |
); |
| 111 |
} |
| 112 |
|
| 113 |
fn get_syntaxrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]get_syntax().<'a>( |
| 114 |
syntax_set: &'a SyntaxSetrust-analyzer cargo syntect 5.3.0 parsing/syntax_set/SyntaxSet#, |
| 115 |
filename: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>, |
| 116 |
fallback: &str, |
| 117 |
) -> &'a SyntaxReferencerust-analyzer cargo syntect 5.3.0 parsing/syntax_set/SyntaxReference# { |
| 118 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(filename) = filename { |
| 119 |
let path = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().(filename); |
| 120 |
let file_name = path.file_namerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_name().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|n| n.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(""); |
| 121 |
let extension = path.extensionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]extension().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|x| x.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(""); |
| 122 |
|
| 123 |
// Like syntect's `find_syntax_for_file`, without inspecting the file content, plus: |
| 124 |
// If the file has NO extension then look up the whole filename as a |
| 125 |
// syntax definition (if it is longer than 4 bytes). |
| 126 |
// This means file formats like Makefile/Dockerfile/Rakefile etc. will get highlighted, |
| 127 |
// but 1-4 short filenames will not -- even if they, as a whole, match an extension: |
| 128 |
// 'rs' will not get highlighted, while 'x.rs' will. |
| 129 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().extension.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() || file_name.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core 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().4 { |
| 130 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(syntax) = syntax_set |
| 131 |
.find_syntax_by_extensionrust-analyzer cargo syntect 5.3.0 parsing/syntax_set/impl#[SyntaxSet]find_syntax_by_extension().(file_name) |
| 132 |
.or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]or_else().(|| syntax_set.find_syntax_by_extensionrust-analyzer cargo syntect 5.3.0 parsing/syntax_set/impl#[SyntaxSet]find_syntax_by_extension().(extension)) |
| 133 |
{ |
| 134 |
return syntax; |
| 135 |
} |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
// Nothing found, try the user provided fallback, or the internal fallback. |
| 140 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(syntax) = syntax_set.find_syntax_for_filerust-analyzer cargo syntect 5.3.0 parsing/syntax_set/impl#[SyntaxSet]find_syntax_for_file().(fallback).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) { |
| 141 |
syntax |
| 142 |
} else { |
| 143 |
syntax_set |
| 144 |
.find_syntax_by_extensionrust-analyzer cargo syntect 5.3.0 parsing/syntax_set/impl#[SyntaxSet]find_syntax_by_extension().(configrust-analyzer cargo git-delta 0.19.2 config/::SYNTAX_FALLBACK_LANGrust-analyzer cargo git-delta 0.19.2 config/SYNTAX_FALLBACK_LANG.) |
| 145 |
.unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| { |
| 146 |
delta_unreachablerust-analyzer cargo git-delta 0.19.2 config/delta_unreachable().("Failed to find any language syntax definitions.") |
| 147 |
}) |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
pub fn set_highlighterrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]set_highlighter().(&mut self) { |
| 152 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref syntax_theme) = self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config..syntax_themerust-analyzer cargo git-delta 0.19.2 config/Config#syntax_theme. { |
| 153 |
self.highlighterrust-analyzer cargo git-delta 0.19.2 paint/Painter#highlighter. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HighlightLinesrust-analyzer cargo syntect 5.3.0 easy/HighlightLines#::newrust-analyzer cargo syntect 5.3.0 easy/impl#[`HighlightLines<'a>`]new().(self.syntaxrust-analyzer cargo git-delta 0.19.2 paint/Painter#syntax., syntax_theme)) |
| 154 |
}; |
| 155 |
} |
| 156 |
|
| 157 |
pub fn paint_buffered_minus_and_plus_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_buffered_minus_and_plus_lines().(&mut self) { |
| 158 |
if self.minus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#minus_lines..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() && self.plus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#plus_lines..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 159 |
return; |
| 160 |
} |
| 161 |
paint_minus_and_plus_linesrust-analyzer cargo git-delta 0.19.2 paint/paint_minus_and_plus_lines().( |
| 162 |
MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().(&self.minus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#minus_lines., &self.plus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#plus_lines.), |
| 163 |
&mut self.line_numbers_datarust-analyzer cargo git-delta 0.19.2 paint/Painter#line_numbers_data., |
| 164 |
&mut self.highlighterrust-analyzer cargo git-delta 0.19.2 paint/Painter#highlighter., |
| 165 |
&mut self.output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer., |
| 166 |
self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config., |
| 167 |
); |
| 168 |
self.minus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#minus_lines..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().(); |
| 169 |
self.plus_linesrust-analyzer cargo git-delta 0.19.2 paint/Painter#plus_lines..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().(); |
| 170 |
} |
| 171 |
|
| 172 |
pub fn paint_zero_linerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_zero_line().(&mut self, line: &str, state: Staterust-analyzer cargo git-delta 0.19.2 delta/State#) { |
| 173 |
let lines = &[(line.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), state.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().())]; |
| 174 |
let syntax_style_sections = |
| 175 |
get_syntax_style_sections_for_linesrust-analyzer cargo git-delta 0.19.2 paint/get_syntax_style_sections_for_lines().(lines, self.highlighterrust-analyzer cargo git-delta 0.19.2 paint/Painter#highlighter..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().(), self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config.); |
| 176 |
let mut diff_style_sections = 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!![(self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config..zero_stylerust-analyzer cargo git-delta 0.19.2 config/Config#zero_style., lines[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/index/Index#index()..0.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().())]]; // TODO: compute style from state |
| 177 |
Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::update_diff_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]update_diff_style_sections().( |
| 178 |
lines, |
| 179 |
&mut diff_style_sections, |
| 180 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 181 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 182 |
&[false], |
| 183 |
self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config., |
| 184 |
); |
| 185 |
if self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config..side_by_siderust-analyzer cargo git-delta 0.19.2 config/Config#side_by_side. { |
| 186 |
// `lines[0].0` so the line has the '\n' already added (as in the +- case) |
| 187 |
side_by_siderust-analyzer cargo git-delta 0.19.2 features/side_by_side/::paint_zero_lines_side_by_siderust-analyzer cargo git-delta 0.19.2 features/side_by_side/paint_zero_lines_side_by_side().( |
| 188 |
&lines[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/index/Index#index()..0, |
| 189 |
syntax_style_sections, |
| 190 |
diff_style_sections, |
| 191 |
&mut self.output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer., |
| 192 |
self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config., |
| 193 |
&mut self.line_numbers_datarust-analyzer cargo git-delta 0.19.2 paint/Painter#line_numbers_data..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().(), |
| 194 |
painted_prefixrust-analyzer cargo git-delta 0.19.2 paint/painted_prefix().(state, self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config.), |
| 195 |
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#), |
| 196 |
); |
| 197 |
} else { |
| 198 |
Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::paint_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_lines().( |
| 199 |
lines, |
| 200 |
&syntax_style_sections, |
| 201 |
diff_style_sections.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().(), |
| 202 |
&[false], |
| 203 |
&mut self.output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer., |
| 204 |
self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config., |
| 205 |
&mut self.line_numbers_datarust-analyzer cargo git-delta 0.19.2 paint/Painter#line_numbers_data..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().(), |
| 206 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 207 |
BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#::defaultrust-analyzer cargo git-delta 0.19.2 paint/impl#[BgShouldFill][Default]default().(), |
| 208 |
); |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
/// Superimpose background styles and foreground syntax |
| 213 |
/// highlighting styles, and write colored lines to output buffer. |
| 214 |
#[allow(clippy::too_many_arguments)] |
| 215 |
pub fn paint_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_lines().<'a>( |
| 216 |
lines: &'a [(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#)], |
| 217 |
syntax_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#>], |
| 218 |
diff_style_sections: &[LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>], |
| 219 |
lines_have_homolog: &[bool], |
| 220 |
output_buffer: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 221 |
config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 222 |
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#>, |
| 223 |
empty_line_style: 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 style with background color to highlight an empty line |
| 224 |
background_color_extends_to_terminal_width: BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#, |
| 225 |
) { |
| 226 |
// There's some unfortunate hackery going on here for two reasons: |
| 227 |
// |
| 228 |
// 1. The prefix needs to be injected into the output stream. |
| 229 |
// |
| 230 |
// 2. We must ensure that we fill rightwards with the appropriate |
| 231 |
// non-emph background color. In that case we don't use the last |
| 232 |
// style of the line, because this might be emph. |
| 233 |
for ((((_, state), syntax_sections), diff_sections), &line_has_homolog) in lines |
| 234 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 235 |
.zip_eqrust-analyzer cargo itertools 0.14.0 Itertools#zip_eq().(syntax_style_sections) |
| 236 |
.zip_eqrust-analyzer cargo itertools 0.14.0 Itertools#zip_eq().(diff_style_sections) |
| 237 |
.zip_eqrust-analyzer cargo itertools 0.14.0 Itertools#zip_eq().(lines_have_homolog) |
| 238 |
{ |
| 239 |
let (mut 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().( |
| 240 |
syntax_sections, |
| 241 |
diff_sections, |
| 242 |
state, |
| 243 |
line_numbers_data, |
| 244 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 245 |
painted_prefixrust-analyzer cargo git-delta 0.19.2 paint/painted_prefix().(state.clonerust-analyzer cargo git-delta 0.19.2 delta/impl#[State][Clone]clone().(), config), |
| 246 |
config, |
| 247 |
); |
| 248 |
let (bg_fill_mode, fill_style) = |
| 249 |
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().( |
| 250 |
diff_sections, |
| 251 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line_has_homolog), |
| 252 |
state, |
| 253 |
background_color_extends_to_terminal_width, |
| 254 |
config, |
| 255 |
); |
| 256 |
|
| 257 |
if let 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#) = bg_fill_mode { |
| 258 |
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().(&mut line, fill_style); |
| 259 |
} else if let 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#) = bg_fill_mode { |
| 260 |
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().(&line); |
| 261 |
line.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().( |
| 262 |
#[allow(clippy::unnecessary_to_owned)] |
| 263 |
&fill_style |
| 264 |
.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().(config.available_terminal_widthrust-analyzer cargo git-delta 0.19.2 config/Config#available_terminal_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)) |
| 265 |
.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 266 |
); |
| 267 |
} else if line_is_empty { |
| 268 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(empty_line_style) = empty_line_style { |
| 269 |
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().( |
| 270 |
&empty_line_style, |
| 271 |
&mut line, |
| 272 |
if config.line_numbersrust-analyzer cargo git-delta 0.19.2 config/Config#line_numbers. { Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(" ") } else { Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# }, |
| 273 |
); |
| 274 |
} |
| 275 |
}; |
| 276 |
|
| 277 |
output_buffer.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&line); |
| 278 |
output_buffer.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n'); |
| 279 |
} |
| 280 |
} |
| 281 |
|
| 282 |
/// Write painted line to the output buffer, with syntax-highlighting and `style` superimposed. |
| 283 |
// Note that, if passing `style_sections` as |
| 284 |
// `StyleSectionSpecifier::StyleSections`, then tabs must already have been |
| 285 |
// expanded in the text. |
| 286 |
pub fn syntax_highlight_and_paint_linerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]syntax_highlight_and_paint_line().( |
| 287 |
&mut self, |
| 288 |
line: &str, |
| 289 |
style_sections: StyleSectionSpecifierrust-analyzer cargo git-delta 0.19.2 paint/StyleSectionSpecifier#, |
| 290 |
state: Staterust-analyzer cargo git-delta 0.19.2 delta/State#, |
| 291 |
background_color_extends_to_terminal_width: BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#, |
| 292 |
) { |
| 293 |
let lines = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(tabsrust-analyzer cargo git-delta 0.19.2 utils/tabs/::expandrust-analyzer cargo git-delta 0.19.2 utils/tabs/expand().(line, &self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config..tab_cfgrust-analyzer cargo git-delta 0.19.2 config/Config#tab_cfg.), state)]; |
| 294 |
let syntax_style_sections = |
| 295 |
get_syntax_style_sections_for_linesrust-analyzer cargo git-delta 0.19.2 paint/get_syntax_style_sections_for_lines().(&lines, self.highlighterrust-analyzer cargo git-delta 0.19.2 paint/Painter#highlighter..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().(), self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config.); |
| 296 |
let diff_style_sections = match style_sections { |
| 297 |
StyleSectionSpecifierrust-analyzer cargo git-delta 0.19.2 paint/StyleSectionSpecifier#::Stylerust-analyzer cargo git-delta 0.19.2 paint/StyleSectionSpecifier#Style#(style) => 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!![(style, 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()..0.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().())]], |
| 298 |
StyleSectionSpecifierrust-analyzer cargo git-delta 0.19.2 paint/StyleSectionSpecifier#::StyleSectionsrust-analyzer cargo git-delta 0.19.2 paint/StyleSectionSpecifier#StyleSections#(style_sections) => vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![style_sections], |
| 299 |
}; |
| 300 |
Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::paint_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_lines().( |
| 301 |
&lines, |
| 302 |
&syntax_style_sections, |
| 303 |
&diff_style_sections, |
| 304 |
&[false], |
| 305 |
&mut self.output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer., |
| 306 |
self.configrust-analyzer cargo git-delta 0.19.2 paint/Painter#config., |
| 307 |
&mut Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 308 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 309 |
background_color_extends_to_terminal_width, |
| 310 |
); |
| 311 |
} |
| 312 |
|
| 313 |
/// Determine whether the terminal should fill the line rightwards with a background color, and |
| 314 |
/// the style for doing so. |
| 315 |
pub fn 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().( |
| 316 |
diff_sections: &[(Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, &str)], |
| 317 |
line_has_homolog: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>, |
| 318 |
state: &Staterust-analyzer cargo git-delta 0.19.2 delta/State#, |
| 319 |
background_color_extends_to_terminal_width: BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#, |
| 320 |
config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 321 |
) -> (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#) { |
| 322 |
let fill_style = match state { |
| 323 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(_, 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#::HunkMinusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinusWrapped# => { |
| 324 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(true) = line_has_homolog { |
| 325 |
config.minus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_non_emph_style. |
| 326 |
} else { |
| 327 |
config.minus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_style. |
| 328 |
} |
| 329 |
} |
| 330 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(_, 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#::HunkZeroWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkZeroWrapped# => config.zero_stylerust-analyzer cargo git-delta 0.19.2 config/Config#zero_style., |
| 331 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(_, 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#::HunkPlusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlusWrapped# => { |
| 332 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(true) = line_has_homolog { |
| 333 |
config.plus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_non_emph_style. |
| 334 |
} else { |
| 335 |
config.plus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_style. |
| 336 |
} |
| 337 |
} |
| 338 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(_, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_)) |
| 339 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(_, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_)) |
| 340 |
| 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#(_)) => { |
| 341 |
// Consider the following raw line, from git colorMoved: |
| 342 |
// ␛[1;36m+␛[m␛[1;36mclass·X:·pass␛[m␊ The last style section returned by |
| 343 |
// parse_style_sections will be a default style associated with the terminal newline |
| 344 |
// character; we want the last "real" style. |
| 345 |
diff_sections |
| 346 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 347 |
.revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() |
| 348 |
.filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|(_, s)| s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().&"\n") |
| 349 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(style, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().style) |
| 350 |
.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().() |
| 351 |
.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(config.null_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_style.) |
| 352 |
} |
| 353 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::Blamerust-analyzer cargo git-delta 0.19.2 delta/State#Blame#(_) => diff_sections[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/index/Index#index()..0, |
| 354 |
_ => config.null_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_style., |
| 355 |
}; |
| 356 |
|
| 357 |
match ( |
| 358 |
fill_style.get_background_colorrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]get_background_color().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().(), |
| 359 |
background_color_extends_to_terminal_width, |
| 360 |
) { |
| 361 |
(false, _) | (_, BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#::Norust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#No#) => (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, fill_style), |
| 362 |
(_, BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#::Withrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#With#(bgmode)) => { |
| 363 |
if config.background_color_extends_to_terminal_widthrust-analyzer cargo git-delta 0.19.2 config/Config#background_color_extends_to_terminal_width. { |
| 364 |
(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(bgmode), fill_style) |
| 365 |
} else { |
| 366 |
(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, fill_style) |
| 367 |
} |
| 368 |
} |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
/// Emit line with ANSI sequences that extend the background color to the terminal width. |
| 373 |
pub fn right_fill_background_colorrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]right_fill_background_color().(line: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, fill_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#) { |
| 374 |
// HACK: How to properly incorporate the ANSI_CSI_CLEAR_TO_EOL into ansi_strings? |
| •375 |
line.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::AnsiStringsrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiStrings().(&[fill_style.paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().("")]).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 376 |
if line |
| 377 |
.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().() |
| 378 |
.ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().(&ansirust-analyzer cargo git-delta 0.19.2 ansi/::ANSI_SGR_RESETrust-analyzer cargo git-delta 0.19.2 ansi/ANSI_SGR_RESET..to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().()) |
| 379 |
{ |
| 380 |
line.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]truncate().(line.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]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().ansirust-analyzer cargo git-delta 0.19.2 ansi/::ANSI_SGR_RESETrust-analyzer cargo git-delta 0.19.2 ansi/ANSI_SGR_RESET..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()); |
| 381 |
} |
| 382 |
line.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(ansirust-analyzer cargo git-delta 0.19.2 ansi/::ANSI_CSI_CLEAR_TO_EOLrust-analyzer cargo git-delta 0.19.2 ansi/ANSI_CSI_CLEAR_TO_EOL.); |
| 383 |
line.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(ansirust-analyzer cargo git-delta 0.19.2 ansi/::ANSI_SGR_RESETrust-analyzer cargo git-delta 0.19.2 ansi/ANSI_SGR_RESET.); |
| 384 |
} |
| 385 |
|
| 386 |
/// Use ANSI sequences to visually mark the current line as empty. If `marker` is None then the |
| 387 |
/// line is marked using terminal emulator colors only, i.e. without appending any marker text |
| 388 |
/// to the line. This is typically appropriate only when the `line` buffer is empty, since |
| 389 |
/// otherwise the ANSI_CSI_CLEAR_TO_BOL instruction would overwrite the text to the left of the |
| 390 |
/// current buffer position. |
| 391 |
pub fn mark_empty_linerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]mark_empty_line().(empty_line_style: &Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, line: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, marker: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) { |
| 392 |
line.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().( |
| 393 |
#[allow(clippy::unnecessary_to_owned)] |
| 394 |
&empty_line_style |
| 395 |
.paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(marker.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(ansirust-analyzer cargo git-delta 0.19.2 ansi/::ANSI_CSI_CLEAR_TO_BOLrust-analyzer cargo git-delta 0.19.2 ansi/ANSI_CSI_CLEAR_TO_BOL.)) |
| 396 |
.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 397 |
); |
| 398 |
} |
| 399 |
|
| 400 |
/// Return painted line (maybe prefixed with line numbers field) and an is_empty? boolean. |
| 401 |
pub fn paint_linerust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_line().( |
| 402 |
syntax_sections: &[(SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, &str)], |
| 403 |
diff_sections: &[(Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, &str)], |
| 404 |
state: &Staterust-analyzer cargo git-delta 0.19.2 delta/State#, |
| 405 |
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#>, |
| 406 |
side_by_side_panel: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PanelSiderust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#>, |
| •407 |
mut 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#>, |
| 408 |
config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 409 |
) -> (Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, bool) { |
| 410 |
let mut ansi_strings = 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().(); |
| 411 |
|
| 412 |
let output_line_numbers = line_numbers_data.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().(); |
| 413 |
if output_line_numbers { |
| 414 |
// Unified diff lines are printed in one go, but side-by-side lines |
| 415 |
// are printed in two parts, so do not increment line numbers when the |
| 416 |
// first (left) part is printed. |
| 417 |
let increment = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(side_by_side_panel, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(side_by_siderust-analyzer cargo git-delta 0.19.2 features/side_by_side/::Leftrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlusIndex#Minus#)); |
| 418 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((line_numbers, styles)) = line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::linenumbers_and_stylesrust-analyzer cargo git-delta 0.19.2 features/line_numbers/linenumbers_and_styles().( |
| 419 |
line_numbers_data.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 420 |
state, |
| 421 |
config, |
| 422 |
increment, |
| 423 |
) { |
| 424 |
ansi_strings.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/::format_and_paint_line_numbersrust-analyzer cargo git-delta 0.19.2 features/line_numbers/format_and_paint_line_numbers().( |
| 425 |
line_numbers_data.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 426 |
side_by_side_panel, |
| 427 |
styles, |
| 428 |
line_numbers, |
| 429 |
config, |
| 430 |
)) |
| 431 |
} |
| 432 |
} |
| 433 |
let superimposed = superimpose_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/superimpose_style_sections().( |
| 434 |
syntax_sections, |
| 435 |
diff_sections, |
| 436 |
config.true_colorrust-analyzer cargo git-delta 0.19.2 config/Config#true_color., |
| 437 |
config.null_syntect_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_syntect_style., |
| 438 |
); |
| 439 |
|
| 440 |
let mut handled_prefix = false; |
| 441 |
for (section_style, text) in &superimposed { |
| 442 |
// If requested re-insert the +/- prefix with proper styling. |
| 443 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().handled_prefix { |
| 444 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(painted_prefix) = painted_prefix.takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 445 |
ansi_strings.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(painted_prefix) |
| 446 |
} |
| 447 |
} |
| 448 |
|
| 449 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().text.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() { |
| 450 |
ansi_strings.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(section_style.paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(text.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().())); |
| 451 |
} |
| 452 |
handled_prefix = true; |
| 453 |
} |
| 454 |
|
| 455 |
// Only if syntax is empty (implies diff empty) can a line actually be empty. |
| 456 |
let is_empty = syntax_sections.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().(); |
| •457 |
(ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::AnsiStringsrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiStrings().(&ansi_strings).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), is_empty) |
| 458 |
} |
| 459 |
|
| 460 |
/// Write output buffer to output stream, and clear the buffer. |
| 461 |
pub fn emitrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]emit().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 462 |
writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(self.writerrust-analyzer cargo git-delta 0.19.2 paint/Painter#writer., "{}", self.output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 463 |
self.output_bufferrust-analyzer cargo git-delta 0.19.2 paint/Painter#output_buffer..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]clear().(); |
| 464 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 465 |
} |
| 466 |
|
| 467 |
pub fn should_compute_syntax_highlightingrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]should_compute_syntax_highlighting().(state: &Staterust-analyzer cargo git-delta 0.19.2 delta/State#, config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#) -> bool { |
| 468 |
if config.syntax_themerust-analyzer cargo git-delta 0.19.2 config/Config#syntax_theme..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 469 |
return false; |
| 470 |
} |
| 471 |
match state { |
| 472 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(_, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => { |
| 473 |
config.minus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_style..is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted. |
| 474 |
|| config.minus_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_emph_style..is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted. |
| 475 |
|| config.minus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_non_emph_style..is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted. |
| 476 |
} |
| 477 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(_, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => config.zero_stylerust-analyzer cargo git-delta 0.19.2 config/Config#zero_style..is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted., |
| 478 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(_, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => { |
| 479 |
config.plus_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_style..is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted. |
| 480 |
|| config.plus_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_emph_style..is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted. |
| 481 |
|| config.plus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_non_emph_style..is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted. |
| 482 |
} |
| 483 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#HunkHeader#(_, _, _, _) => true, |
| 484 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(_, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_raw_line)) |
| 485 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(_, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_raw_line)) |
| 486 |
| 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#(_raw_line)) => { |
| 487 |
// It is possible that the captured raw line contains an ANSI |
| 488 |
// style that has been mapped (via map-styles) to a delta Style |
| 489 |
// with syntax-highlighting. |
| 490 |
true |
| 491 |
} |
| 492 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::Blamerust-analyzer cargo git-delta 0.19.2 delta/State#Blame#(_) => true, |
| 493 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::GitShowFilerust-analyzer cargo git-delta 0.19.2 delta/State#GitShowFile# => true, |
| 494 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::Greprust-analyzer cargo git-delta 0.19.2 delta/State#Grep#(_, _, _, _) => true, |
| 495 |
Staterust-analyzer cargo git-delta 0.19.2 delta/State#::Unknownrust-analyzer cargo git-delta 0.19.2 delta/State#Unknown# |
| 496 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::CommitMetarust-analyzer cargo git-delta 0.19.2 delta/State#CommitMeta# |
| 497 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::DiffHeaderrust-analyzer cargo git-delta 0.19.2 delta/State#DiffHeader#(_) |
| 498 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinusWrapped# |
| 499 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZeroWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkZeroWrapped# |
| 500 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkPlusWrappedrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlusWrapped# |
| 501 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::MergeConflictrust-analyzer cargo git-delta 0.19.2 delta/State#MergeConflict#(_, _) |
| 502 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::SubmoduleLogrust-analyzer cargo git-delta 0.19.2 delta/State#SubmoduleLog# |
| 503 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::SubmoduleShortrust-analyzer cargo git-delta 0.19.2 delta/State#SubmoduleShort#(_) => { |
| 504 |
panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!( |
| 505 |
"should_compute_syntax_highlighting is undefined for state {:?}", |
| 506 |
state |
| 507 |
) |
| 508 |
} |
| 509 |
} |
| 510 |
} |
| 511 |
|
| 512 |
/// There are some rules according to which we update line section styles that were computed |
| 513 |
/// during the initial edit inference pass. This function applies those rules. The rules are |
| 514 |
/// 1. If there are multiple diff styles in the line, then the line must have some |
| 515 |
/// inferred edit operations and so, if there is a special non-emph style that is |
| 516 |
/// distinct from the default style, then it should be used for the non-emph style |
| 517 |
/// sections. |
| 518 |
/// 2. If the line constitutes a whitespace error, then the whitespace error style |
| 519 |
/// should be applied to the added material. |
| 520 |
/// 3. If delta recognized the raw line as one containing ANSI colors that |
| 521 |
/// are going to be preserved in the output, then replace delta's |
| 522 |
/// computed diff styles with these styles from the raw line. (This is |
| 523 |
/// how support for git's --color-moved is implemented.) |
| 524 |
fn update_diff_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]update_diff_style_sections().<'a>( |
| 525 |
lines: &'a [(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#)], |
| 526 |
diff_style_sections: &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#>>, |
| 527 |
whitespace_error_style: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>, |
| 528 |
non_emph_style: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>, |
| 529 |
lines_have_homolog: &[bool], |
| 530 |
config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 531 |
) { |
| 532 |
for (((_, state), style_sections), line_has_homolog) in lines |
| 533 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 534 |
.zip_eqrust-analyzer cargo itertools 0.14.0 Itertools#zip_eq().(diff_style_sections) |
| 535 |
.zip_eqrust-analyzer cargo itertools 0.14.0 Itertools#zip_eq().(lines_have_homolog) |
| 536 |
{ |
| 537 |
if let Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(_, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(raw_line)) |
| 538 |
| Staterust-analyzer cargo git-delta 0.19.2 delta/State#::HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(_, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(raw_line)) |
| 539 |
| 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#(raw_line)) = state |
| 540 |
{ |
| 541 |
// raw_line is captured in handle_hunk_line under certain conditions. If we have |
| 542 |
// done so, then overwrite the style sections with styles parsed directly from the |
| 543 |
// raw line. Currently the only reason this is done is to handle a diff.colorMoved |
| 544 |
// line. |
| 545 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().style_sections = parse_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/parse_style_sections().(raw_line, config); |
| 546 |
continue; |
| 547 |
} |
| 548 |
let line_has_emph_and_non_emph_sections = |
| 549 |
style_sections_contain_more_than_one_stylerust-analyzer cargo git-delta 0.19.2 paint/style_sections_contain_more_than_one_style().(style_sections); |
| 550 |
let should_update_non_emph_styles = non_emph_style.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() && *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().line_has_homolog; |
| 551 |
|
| 552 |
// TODO: Git recognizes blank lines at end of file (blank-at-eof) |
| 553 |
// as a whitespace error but delta does not yet. |
| 554 |
// https://git-scm.com/docs/git-config#Documentation/git-config.txt-corewhitespace |
| 555 |
let mut is_whitespace_error = whitespace_error_style.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().(); |
| 556 |
for (style, s) in style_sections.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() { |
| 557 |
if is_whitespace_error && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 558 |
is_whitespace_error = false; |
| 559 |
} |
| 560 |
// If the line as a whole constitutes a whitespace error then highlight this |
| 561 |
// section if either (a) it is an emph section, or (b) the line lacks any |
| 562 |
// emph/non-emph distinction. |
| 563 |
|
| 564 |
// TODO: is this logic correct now, after introducing |
| 565 |
// line_has_homolog for non_emph style? |
| 566 |
if is_whitespace_error && (style.is_emphrust-analyzer cargo git-delta 0.19.2 style/Style#is_emph. || !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().line_has_emph_and_non_emph_sections) { |
| 567 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().style = whitespace_error_style.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 568 |
} |
| 569 |
// Otherwise, update the style if this is a non-emph section that needs updating. |
| 570 |
else if should_update_non_emph_styles && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().style.is_emphrust-analyzer cargo git-delta 0.19.2 style/Style#is_emph. { |
| 571 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().style = non_emph_style.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 572 |
if is_whitespace_error { |
| 573 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().style = whitespace_error_style.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 574 |
} |
| 575 |
} |
| 576 |
} |
| 577 |
} |
| 578 |
} |
| 579 |
} |
| 580 |
|
| 581 |
/// Remove initial -/+ character, expand tabs as spaces, and terminate with newline. |
| 582 |
// Terminating with newline character is necessary for many of the sublime syntax definitions to |
| 583 |
// highlight correctly. |
| 584 |
// See https://docs.rs/syntect/3.2.0/syntect/parsing/struct.SyntaxSetBuilder.html#method.add_from_folder |
| 585 |
pub fn preparerust-analyzer cargo git-delta 0.19.2 paint/prepare().(line: &str, prefix_length: usize, config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 586 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().line.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 587 |
// The prefix contains -/+/space characters, added by git. We removes them now so they |
| 588 |
// are not present during syntax highlighting or wrapping. If --keep-plus-minus-markers |
| 589 |
// is in effect the prefix is re-inserted in Painter::paint_line. |
| 590 |
let mut line = tabsrust-analyzer cargo git-delta 0.19.2 utils/tabs/::remove_prefix_and_expandrust-analyzer cargo git-delta 0.19.2 utils/tabs/remove_prefix_and_expand().(prefix_length, line, &config.tab_cfgrust-analyzer cargo git-delta 0.19.2 config/Config#tab_cfg.); |
| 591 |
line.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n'); |
| 592 |
line |
| 593 |
} else { |
| 594 |
"\n".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 595 |
} |
| 596 |
} |
| 597 |
|
| 598 |
// Remove initial -/+ characters, expand tabs as spaces, retaining ANSI sequences. Terminate with |
| 599 |
// newline character. |
| 600 |
pub fn prepare_raw_linerust-analyzer cargo git-delta 0.19.2 paint/prepare_raw_line().(raw_line: &str, prefix_length: usize, config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 601 |
let mut line = tabsrust-analyzer cargo git-delta 0.19.2 utils/tabs/::expandrust-analyzer cargo git-delta 0.19.2 utils/tabs/expand().(raw_line, &config.tab_cfgrust-analyzer cargo git-delta 0.19.2 config/Config#tab_cfg.); |
| 602 |
line.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n'); |
| 603 |
ansirust-analyzer cargo git-delta 0.19.2 ansi/::ansi_preserving_slicerust-analyzer cargo git-delta 0.19.2 ansi/ansi_preserving_slice().(&line, prefix_length) |
| 604 |
} |
| 605 |
|
| 606 |
pub fn paint_minus_and_plus_linesrust-analyzer cargo git-delta 0.19.2 paint/paint_minus_and_plus_lines().( |
| 607 |
lines: MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#<&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#)>>, |
| 608 |
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#>, |
| 609 |
highlighter: &mut Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<HighlightLinesrust-analyzer cargo syntect 5.3.0 easy/HighlightLines#>, |
| 610 |
output_buffer: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 611 |
config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 612 |
) { |
| 613 |
let syntax_style_sections = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().( |
| 614 |
get_syntax_style_sections_for_linesrust-analyzer cargo git-delta 0.19.2 paint/get_syntax_style_sections_for_lines().(lines[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Minusrust-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()., highlighter.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().(), config), |
| 615 |
get_syntax_style_sections_for_linesrust-analyzer cargo git-delta 0.19.2 paint/get_syntax_style_sections_for_lines().(lines[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Plusrust-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()., highlighter.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().(), config), |
| 616 |
); |
| 617 |
let (mut diff_style_sections, line_alignment) = get_diff_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/get_diff_style_sections().(&lines, config); |
| 618 |
let lines_have_homolog = 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); |
| 619 |
Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::update_diff_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]update_diff_style_sections().( |
| 620 |
lines[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Minusrust-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()., |
| 621 |
&mut diff_style_sections[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut().Minusrust-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()., |
| 622 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 623 |
if config.minus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_non_emph_style. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().config.minus_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_emph_style. { |
| 624 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.minus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_non_emph_style.) |
| 625 |
} else { |
| 626 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 627 |
}, |
| 628 |
&lines_have_homolog[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Minusrust-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()., |
| 629 |
config, |
| 630 |
); |
| 631 |
Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::update_diff_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]update_diff_style_sections().( |
| 632 |
lines[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Plusrust-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()., |
| 633 |
&mut diff_style_sections[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`IndexMut<MinusPlusIndex>`]index_mut().Plusrust-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()., |
| 634 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.whitespace_error_stylerust-analyzer cargo git-delta 0.19.2 config/Config#whitespace_error_style.), |
| 635 |
if config.plus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_non_emph_style. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().config.plus_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_emph_style. { |
| 636 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.plus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_non_emph_style.) |
| 637 |
} else { |
| 638 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 639 |
}, |
| 640 |
&lines_have_homolog[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Plusrust-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()., |
| 641 |
config, |
| 642 |
); |
| 643 |
if config.side_by_siderust-analyzer cargo git-delta 0.19.2 config/Config#side_by_side. { |
| 644 |
side_by_siderust-analyzer cargo git-delta 0.19.2 features/side_by_side/::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().( |
| 645 |
lines, |
| 646 |
syntax_style_sections, |
| 647 |
diff_style_sections, |
| 648 |
lines_have_homolog, |
| 649 |
line_alignment, |
| 650 |
line_numbers_data, |
| 651 |
output_buffer, |
| 652 |
config, |
| 653 |
) |
| 654 |
} else { |
| 655 |
// Unified diff mode: |
| 656 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().lines[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Minusrust-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()..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 657 |
Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::paint_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_lines().( |
| 658 |
lines[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Minusrust-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()., |
| 659 |
&syntax_style_sections[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Minusrust-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()., |
| 660 |
&diff_style_sections[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Minusrust-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()., |
| 661 |
&lines_have_homolog[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Minusrust-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()., |
| 662 |
output_buffer, |
| 663 |
config, |
| 664 |
&mut line_numbers_data.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().(), |
| 665 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.minus_empty_line_marker_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_empty_line_marker_style.), |
| 666 |
BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#::defaultrust-analyzer cargo git-delta 0.19.2 paint/impl#[BgShouldFill][Default]default().(), |
| 667 |
); |
| 668 |
} |
| 669 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().lines[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Plusrust-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()..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 670 |
Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::paint_linesrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]paint_lines().( |
| 671 |
lines[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Plusrust-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()., |
| 672 |
&syntax_style_sections[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Plusrust-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()., |
| 673 |
&diff_style_sections[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Plusrust-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()., |
| 674 |
&lines_have_homolog[rust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`][`Index<MinusPlusIndex>`]index().Plusrust-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()., |
| 675 |
output_buffer, |
| 676 |
config, |
| 677 |
&mut line_numbers_data.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().(), |
| 678 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.plus_empty_line_marker_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_empty_line_marker_style.), |
| 679 |
BgShouldFillrust-analyzer cargo git-delta 0.19.2 paint/BgShouldFill#::defaultrust-analyzer cargo git-delta 0.19.2 paint/impl#[BgShouldFill][Default]default().(), |
| 680 |
); |
| 681 |
} |
| 682 |
} |
| 683 |
} |
| 684 |
|
| 685 |
pub fn get_syntax_style_sections_for_linesrust-analyzer cargo git-delta 0.19.2 paint/get_syntax_style_sections_for_lines().<'a>( |
| 686 |
lines: &'a [(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Staterust-analyzer cargo git-delta 0.19.2 delta/State#)], |
| 687 |
highlighter: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut HighlightLinesrust-analyzer cargo syntect 5.3.0 easy/HighlightLines#>, |
| 688 |
config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 689 |
) -> 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#>> { |
| 690 |
let mut line_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().(); |
| 691 |
match ( |
| 692 |
highlighter, |
| 693 |
lines |
| 694 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 695 |
.anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|(_, state)| Painterrust-analyzer cargo git-delta 0.19.2 paint/Painter#::should_compute_syntax_highlightingrust-analyzer cargo git-delta 0.19.2 paint/impl#[`Painter<'p>`]should_compute_syntax_highlighting().(state, config)), |
| 696 |
) { |
| 697 |
(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(highlighter), true) => { |
| 698 |
for (line, _) in lines.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 699 |
// Fast but simple length comparison. Overcounts non-printable ansi |
| 700 |
// characters or wider UTF-8, but `truncate_str_short` in the |
| 701 |
// else branch corrects that. |
| 702 |
if line.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]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().config.max_syntax_lengthrust-analyzer cargo git-delta 0.19.2 config/Config#max_syntax_length. || config.max_syntax_lengthrust-analyzer cargo git-delta 0.19.2 config/Config#max_syntax_length. 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 { |
| 703 |
line_sections.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().( |
| 704 |
highlighter |
| 705 |
.highlight_linerust-analyzer cargo syntect 5.3.0 easy/impl#[`HighlightLines<'a>`]highlight_line().(line, &config.syntax_setrust-analyzer cargo git-delta 0.19.2 config/Config#syntax_set.) |
| 706 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 707 |
); |
| 708 |
} else { |
| 709 |
let line_syntax = ansirust-analyzer cargo git-delta 0.19.2 ansi/::truncate_str_shortrust-analyzer cargo git-delta 0.19.2 ansi/truncate_str_short().(line, config.max_syntax_lengthrust-analyzer cargo git-delta 0.19.2 config/Config#max_syntax_length.); |
| 710 |
// Re-split to get references into `line` with correct lifetimes. |
| 711 |
// SAFETY: slicing the string is safe because `truncate_str_short` always |
| 712 |
// returns a prefix of the input and only cuts at grapheme borders. |
| 713 |
let (with_syntax, plain) = line.split_atrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_at().(line_syntax.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()); |
| 714 |
// Note: splitting a line and only feeding one half to the highlighter may |
| 715 |
// result in wrong highlighting until it is reset the next hunk. |
| 716 |
// |
| 717 |
// Also, as lines are no longer newline terminated they might not be |
| 718 |
// highlighted correctly, and because of lifetimes inserting '\n' here is not |
| 719 |
// possible, also see `prepare()`. |
| 720 |
line_sections.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().( |
| 721 |
highlighter |
| 722 |
.highlight_linerust-analyzer cargo syntect 5.3.0 easy/impl#[`HighlightLines<'a>`]highlight_line().(with_syntax, &config.syntax_setrust-analyzer cargo git-delta 0.19.2 config/Config#syntax_set.) |
| 723 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 724 |
); |
| 725 |
|
| 726 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().plain.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 727 |
line_sections |
| 728 |
.last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().() |
| 729 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 730 |
.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((config.null_syntect_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_syntect_style., plain)); |
| 731 |
} |
| 732 |
} |
| 733 |
} |
| 734 |
} |
| 735 |
_ => { |
| 736 |
for (line, _) in lines.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 737 |
line_sections.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 macros/vec!![(config.null_syntect_stylerust-analyzer cargo git-delta 0.19.2 config/Config#null_syntect_style., line.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().())]) |
| 738 |
} |
| 739 |
} |
| 740 |
} |
| 741 |
line_sections |
| 742 |
} |
| 743 |
|
| 744 |
/// Get background styles to represent diff for minus and plus lines in buffer. |
| 745 |
#[allow(clippy::type_complexity)] |
| 746 |
fn get_diff_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/get_diff_style_sections().<'a>( |
| 747 |
lines: &MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#<&'a 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#)>>, |
| 748 |
config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 749 |
) -> ( |
| 750 |
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#>>>, |
| 751 |
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>)>, |
| 752 |
) { |
| 753 |
let (minus_lines, minus_styles): (Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&str>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>) = lines[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().Minusrust-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(). |
| 754 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 755 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(s, state)| (s.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(), *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().config.get_stylerust-analyzer cargo git-delta 0.19.2 config/impl#[Config]get_style().(state))) |
| 756 |
.unziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#unzip().(); |
| 757 |
let (plus_lines, plus_styles): (Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&str>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>) = lines[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().Plusrust-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(). |
| 758 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 759 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(s, state)| (s.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(), *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().config.get_stylerust-analyzer cargo git-delta 0.19.2 config/impl#[Config]get_style().(state))) |
| 760 |
.unziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#unzip().(); |
| 761 |
let (minus_line_diff_style_sections, plus_line_diff_style_sections, line_alignment) = |
| 762 |
editsrust-analyzer cargo git-delta 0.19.2 edits/::infer_editsrust-analyzer cargo git-delta 0.19.2 edits/infer_edits().( |
| 763 |
minus_lines, |
| 764 |
plus_lines, |
| 765 |
minus_styles, |
| 766 |
config.minus_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#minus_emph_style., // FIXME |
| 767 |
plus_styles, |
| 768 |
config.plus_emph_stylerust-analyzer cargo git-delta 0.19.2 config/Config#plus_emph_style., // FIXME |
| 769 |
&config.tokenization_regexrust-analyzer cargo git-delta 0.19.2 config/Config#tokenization_regex., |
| 770 |
config.max_line_distancerust-analyzer cargo git-delta 0.19.2 config/Config#max_line_distance., |
| 771 |
config.max_line_distance_for_naively_paired_linesrust-analyzer cargo git-delta 0.19.2 config/Config#max_line_distance_for_naively_paired_lines., |
| 772 |
); |
| 773 |
let diff_sections = MinusPlusrust-analyzer cargo git-delta 0.19.2 minusplus/MinusPlus#::newrust-analyzer cargo git-delta 0.19.2 minusplus/impl#[`MinusPlus<T>`]new().( |
| 774 |
minus_line_diff_style_sections, |
| 775 |
plus_line_diff_style_sections, |
| 776 |
); |
| 777 |
(diff_sections, line_alignment) |
| 778 |
} |
| 779 |
|
| •780 |
fn painted_prefixrust-analyzer cargo git-delta 0.19.2 paint/painted_prefix().(state: Staterust-analyzer cargo git-delta 0.19.2 delta/State#, config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AnsiStringrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiString#<'_>> { |
| 781 |
use DiffTyperust-analyzer cargo git-delta 0.19.2 delta/DiffType#::*; |
| 782 |
use Staterust-analyzer cargo git-delta 0.19.2 delta/State#::*; |
| 783 |
match (state, config.keep_plus_minus_markersrust-analyzer cargo git-delta 0.19.2 config/Config#keep_plus_minus_markers.) { |
| 784 |
// For a combined diff, unless we are in a merge conflict, we do not honor |
| 785 |
// keep_plus_minus_markers -- i.e. we always emit the prefix -- because there is currently |
| 786 |
// no way to distinguish, say, a '+ ' line from a ' +' line, by styles alone. In a merge |
| 787 |
// conflict we do honor the setting because the way merge conflicts are displayed indicates |
| 788 |
// from which commit the lines derive. |
| 789 |
(HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#::Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), _), _) => { |
| 790 |
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().(prefix)) |
| 791 |
} |
| 792 |
(HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#::Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), _), _) => { |
| 793 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.zero_stylerust-analyzer cargo git-delta 0.19.2 config/Config#zero_style..paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(prefix)) |
| 794 |
} |
| 795 |
(HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(Combinedrust-analyzer cargo git-delta 0.19.2 delta/DiffType#Combined#(MergeParentsrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#::Prefixrust-analyzer cargo git-delta 0.19.2 delta/MergeParents#Prefix#(prefix), InMergeConflictrust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#::Norust-analyzer cargo git-delta 0.19.2 delta/InMergeConflict#No#), _), _) => { |
| 796 |
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().(prefix)) |
| 797 |
} |
| 798 |
// But otherwise we honor keep_plus_minus_markers |
| 799 |
(HunkMinusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkMinus#(_, _), true) => 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().("-".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 800 |
(HunkZerorust-analyzer cargo git-delta 0.19.2 delta/State#HunkZero#(_, _), true) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config.zero_stylerust-analyzer cargo git-delta 0.19.2 config/Config#zero_style..paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(" ".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 801 |
(HunkPlusrust-analyzer cargo git-delta 0.19.2 delta/State#HunkPlus#(_, _), true) => 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().("+".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 802 |
_ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 803 |
} |
| 804 |
} |
| 805 |
|
| 806 |
// Parse ANSI styles encountered in `raw_line` and apply `styles_map`. |
| 807 |
pub fn parse_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/parse_style_sections().<'a>( |
| 808 |
raw_line: &'a str, |
| 809 |
config: &configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 810 |
) -> LineSectionsrust-analyzer cargo git-delta 0.19.2 paint/LineSections#<'a, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#> { |
| 811 |
let empty_map = HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(); |
| 812 |
let styles_map = config.styles_maprust-analyzer cargo git-delta 0.19.2 config/Config#styles_map..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(&empty_map); |
| 813 |
ansirust-analyzer cargo git-delta 0.19.2 ansi/::parse_style_sectionsrust-analyzer cargo git-delta 0.19.2 ansi/parse_style_sections().(raw_line) |
| 814 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 815 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(original_style, s)| { |
| 816 |
match styles_map.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&stylerust-analyzer cargo git-delta 0.19.2 style/::ansi_term_style_equality_keyrust-analyzer cargo git-delta 0.19.2 style/ansi_term_style_equality_key().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().original_style)) { |
| 817 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mapped_style) => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().mapped_style, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s), |
| 818 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => ( |
| 819 |
Stylerust-analyzer cargo git-delta 0.19.2 style/Style# { |
| 820 |
ansi_term_stylerust-analyzer cargo git-delta 0.19.2 style/Style#ansi_term_style.: *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().original_style, |
| 821 |
..Stylerust-analyzer cargo git-delta 0.19.2 style/Style#::defaultrust-analyzer cargo git-delta 0.19.2 style/impl#[Style][Default]default().() |
| 822 |
}, |
| 823 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s, |
| 824 |
), |
| 825 |
} |
| 826 |
}) |
| 827 |
.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 828 |
} |
| 829 |
|
| 830 |
#[allow(clippy::too_many_arguments)] |
| 831 |
pub fn paint_file_path_with_line_numberrust-analyzer cargo git-delta 0.19.2 paint/paint_file_path_with_line_number().( |
| 832 |
line_number: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 833 |
file_path: &str, |
| 834 |
pad_line_number: bool, |
| 835 |
separator: &str, |
| 836 |
terminate_with_separator: bool, |
| 837 |
file_style: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>, // None means do not include file path |
| 838 |
line_number_style: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stylerust-analyzer cargo git-delta 0.19.2 style/Style#>, // None means do not include line number |
| 839 |
config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#, |
| 840 |
) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 841 |
let mut file_with_line_number = 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().(); |
| 842 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(file_style) = file_style { |
| 843 |
let file_path = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(regex_replacement) = &config.file_regex_replacementrust-analyzer cargo git-delta 0.19.2 config/Config#file_regex_replacement. { |
| 844 |
regex_replacement.executerust-analyzer cargo git-delta 0.19.2 utils/regex_replacement/impl#[RegexReplacement]execute().(file_path) |
| 845 |
} else { |
| 846 |
Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`Cow<'a, str>`][`From<&'a str>`]from().(file_path) |
| 847 |
}; |
| 848 |
file_with_line_number.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(file_style.paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(file_path)) |
| 849 |
}; |
| 850 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line_number) = line_number { |
| 851 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line_number_style) = line_number_style { |
| 852 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().file_with_line_number.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| •853 |
file_with_line_number.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::AnsiStringrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiString#::fromrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[`AnsiGenericString<'a, S>`][`From<I>`]from().(separator)); |
| 854 |
} |
| 855 |
file_with_line_number.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(line_number_style.paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{line_number}"))) |
| 856 |
} |
| 857 |
} |
| 858 |
if terminate_with_separator { |
| •859 |
file_with_line_number.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::AnsiGenericStringrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiGenericString#::fromrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[`AnsiGenericString<'a, S>`][`From<I>`]from().(separator)); |
| 860 |
} |
| 861 |
if pad_line_number { |
| 862 |
// If requested we pad line numbers to a width of at least |
| 863 |
// 3, so that we do not see any misalignment up to line |
| 864 |
// number 999. However, see |
| 865 |
// https://github.com/BurntSushi/ripgrep/issues/795 for |
| 866 |
// discussion about aligning grep output. |
| 867 |
match line_number { |
| 868 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) if n 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().10 => { |
| •869 |
file_with_line_number.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::AnsiGenericStringrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiGenericString#::fromrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[`AnsiGenericString<'a, S>`][`From<I>`]from().(" ")) |
| 870 |
} |
| 871 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) if n 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().100 => { |
| •872 |
file_with_line_number.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::AnsiGenericStringrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiGenericString#::fromrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[`AnsiGenericString<'a, S>`][`From<I>`]from().(" ")) |
| 873 |
} |
| 874 |
_ => {} |
| 875 |
} |
| 876 |
} |
| •877 |
let file_with_line_number = ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::AnsiStringsrust-analyzer cargo nu-ansi-term 0.50.3 display/AnsiStrings().(&file_with_line_number).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 878 |
match if config.hyperlinksrust-analyzer cargo git-delta 0.19.2 config/Config#hyperlinks. && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().file_with_line_number.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() { |
| 879 |
utilsrust-analyzer cargo git-delta 0.19.2 utils/::pathrust-analyzer cargo git-delta 0.19.2 utils/path/::absolute_pathrust-analyzer cargo git-delta 0.19.2 utils/path/absolute_path().(file_path, config) |
| 880 |
} else { |
| 881 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 882 |
} { |
| 883 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(absolute_path) => hyperlinksrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/::format_osc8_file_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_osc8_file_hyperlink().( |
| 884 |
absolute_path, |
| 885 |
line_number, |
| 886 |
&file_with_line_number, |
| 887 |
config, |
| 888 |
) |
| 889 |
.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 890 |
_ => file_with_line_number, |
| 891 |
} |
| 892 |
} |
| 893 |
|
| 894 |
// edits::annotate doesn't return "coalesced" annotations (see comment there), so we can't assume |
| 895 |
// that `sections.len() > 1 <=> (multiple styles)`. |
| 896 |
fn style_sections_contain_more_than_one_stylerust-analyzer cargo git-delta 0.19.2 paint/style_sections_contain_more_than_one_style().(sections: &[(Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, &str)]) -> bool { |
| 897 |
if sections.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]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().1 { |
| 898 |
let (first_style, _) = sections[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/index/Index#index().; |
| 899 |
sections.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|(style, _)| *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 cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().first_style) |
| 900 |
} else { |
| 901 |
false |
| 902 |
} |
| 903 |
} |
| 904 |
|
| 905 |
mod superimpose_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/ { |
| 906 |
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#; |
| 907 |
|
| 908 |
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#; |
| 909 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::batrust-analyzer cargo git-delta 0.19.2 utils/bat/::terminalrust-analyzer cargo git-delta 0.19.2 utils/bat/terminal/::to_ansi_colorrust-analyzer cargo git-delta 0.19.2 utils/bat/terminal/to_ansi_color().; |
| 910 |
|
| 911 |
// We have two different annotations of the same line: |
| 912 |
// `syntax_style_sections` contains foreground styles computed by syntect, |
| 913 |
// and `diff_style_sections` contains styles computed by delta reflecting |
| 914 |
// within-line edits. The delta styles may assign a foreground color, or |
| 915 |
// they may indicate that the foreground color comes from syntax |
| 916 |
// highlighting (the is_syntax_highlighting attribute on style::Style). This |
| 917 |
// function takes in the two input streams and outputs one stream with a |
| 918 |
// single style assigned to each character. |
| 919 |
pub fn superimpose_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/superimpose_style_sections().( |
| 920 |
syntax_style_sections: &[(SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, &str)], |
| 921 |
diff_style_sections: &[(Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, &str)], |
| 922 |
true_color: bool, |
| 923 |
null_syntect_style: SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, |
| 924 |
) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)> { |
| 925 |
coalescerust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/coalesce().( |
| 926 |
superimposerust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/superimpose().( |
| 927 |
exploderust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/explode().(syntax_style_sections) |
| 928 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 929 |
.ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(exploderust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/explode().(diff_style_sections)) |
| 930 |
.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#<(&(SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, char), (Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, char))>>(), |
| 931 |
), |
| 932 |
true_color, |
| 933 |
null_syntect_style, |
| 934 |
) |
| 935 |
} |
| 936 |
|
| 937 |
fn exploderust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/explode().<T>(style_sections: &[(T, &str)]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(T, char)> |
| 938 |
where |
| 939 |
T: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 940 |
{ |
| 941 |
let mut exploded: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(T, char)> = 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().(); |
| 942 |
for (style, s) in style_sections { |
| 943 |
for c in s.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().() { |
| 944 |
exploded.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().style, c)); |
| 945 |
} |
| 946 |
} |
| 947 |
exploded |
| 948 |
} |
| 949 |
|
| 950 |
#[allow(clippy::type_complexity)] |
| 951 |
fn superimposerust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/superimpose().( |
| 952 |
style_section_pairs: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(&(SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, char), (Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, char))>, |
| 953 |
) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<((SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#), char)> { |
| 954 |
let mut superimposed: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<((SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#), char)> = 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().(); |
| 955 |
for ((syntax_style, char_1), (style, char_2)) in style_section_pairs { |
| 956 |
if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().char_1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]ne().char_2 { |
| 957 |
panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!( |
| 958 |
"String mismatch encountered while superimposing style sections: '{}' vs '{}'", |
| 959 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().char_1, char_2 |
| 960 |
) |
| 961 |
} |
| 962 |
superimposed.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().syntax_style, style), *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().char_1)); |
| 963 |
} |
| 964 |
superimposed |
| 965 |
} |
| 966 |
|
| 967 |
fn coalescerust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/coalesce().( |
| 968 |
style_sections: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<((SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#), char)>, |
| 969 |
true_color: bool, |
| 970 |
null_syntect_style: SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, |
| 971 |
) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)> { |
| 972 |
let make_superimposed_style = |(syntect_style, style): (SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#)| { |
| 973 |
if style.is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted. && syntect_style rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().null_syntect_style { |
| 974 |
Stylerust-analyzer cargo git-delta 0.19.2 style/Style# { |
| 975 |
ansi_term_stylerust-analyzer cargo git-delta 0.19.2 style/Style#ansi_term_style.: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style# { |
| 976 |
foregroundrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#foreground.: to_ansi_colorrust-analyzer cargo git-delta 0.19.2 utils/bat/terminal/to_ansi_color().(syntect_style.foregroundrust-analyzer cargo syntect 5.3.0 highlighting/style/Style#foreground., true_color), |
| 977 |
..style.ansi_term_stylerust-analyzer cargo git-delta 0.19.2 style/Style#ansi_term_style. |
| 978 |
}, |
| 979 |
..style |
| 980 |
} |
| 981 |
} else { |
| 982 |
style |
| 983 |
} |
| 984 |
}; |
| 985 |
let mut coalesced: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)> = 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().(); |
| 986 |
let mut style_sections = style_sections.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(); |
| 987 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((style_pair, c)) = style_sections.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().() { |
| 988 |
let mut current_string = c.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 989 |
let mut current_style_pair = style_pair; |
| 990 |
for (style_pair, c) in style_sections { |
| 991 |
if style_pair rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().current_style_pair { |
| 992 |
let style = make_superimposed_style(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().current_style_pair); |
| 993 |
coalesced.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((style, current_string)); |
| 994 |
current_string = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 995 |
current_style_pair = style_pair; |
| 996 |
} |
| 997 |
current_string.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c); |
| 998 |
} |
| 999 |
|
| 1000 |
// TODO: This is not the ideal location for the following code. |
| 1001 |
if current_string.ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().('\n') { |
| 1002 |
// Remove the terminating newline whose presence was necessary for the syntax |
| 1003 |
// highlighter to work correctly. |
| 1004 |
current_string.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]truncate().(current_string.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]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().1); |
| 1005 |
} |
| 1006 |
let style = make_superimposed_style(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().current_style_pair); |
| 1007 |
coalesced.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((style, current_string)); |
| 1008 |
} |
| 1009 |
coalesced |
| 1010 |
} |
| 1011 |
|
| 1012 |
#[cfg(test)] |
| 1013 |
mod testsrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/ { |
| 1014 |
use lazy_staticrust-analyzer cargo lazy_static 1.4.0 crate/::lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!; |
| 1015 |
|
| 1016 |
use superrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/::*; |
| 1017 |
use ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::{selfrust-analyzer cargo nu-ansi-term 0.50.3 crate/, Colorrust-analyzer cargo nu-ansi-term 0.50.3 style/Color#}; |
| 1018 |
use syntectrust-analyzer cargo syntect 5.3.0 crate/::highlightingrust-analyzer cargo syntect 5.3.0 highlighting/::Colorrust-analyzer cargo syntect 5.3.0 highlighting/style/Color# as SyntectColorrust-analyzer cargo syntect 5.3.0 highlighting/style/Color#; |
| 1019 |
use syntectrust-analyzer cargo syntect 5.3.0 crate/::highlightingrust-analyzer cargo syntect 5.3.0 highlighting/::FontStylerust-analyzer cargo syntect 5.3.0 highlighting/style/FontStyle# as SyntectFontStylerust-analyzer cargo syntect 5.3.0 highlighting/style/FontStyle#; |
| 1020 |
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#; |
| 1021 |
|
| 1022 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::stylerust-analyzer cargo git-delta 0.19.2 style/::{DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#}; |
| 1023 |
|
| 1024 |
lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! { |
| 1025 |
static ref SYNTAX_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_STYLE#: SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style# = SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style# { |
| 1026 |
foregroundrust-analyzer cargo syntect 5.3.0 highlighting/style/Style#foreground.: SyntectColorrust-analyzer cargo syntect 5.3.0 highlighting/style/Color#::BLACKrust-analyzer cargo syntect 5.3.0 highlighting/style/impl#[Color]BLACK., |
| 1027 |
backgroundrust-analyzer cargo syntect 5.3.0 highlighting/style/Style#background.: SyntectColorrust-analyzer cargo syntect 5.3.0 highlighting/style/Color#::BLACKrust-analyzer cargo syntect 5.3.0 highlighting/style/impl#[Color]BLACK., |
| 1028 |
font_stylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#font_style.: SyntectFontStylerust-analyzer cargo syntect 5.3.0 highlighting/style/FontStyle#::BOLDrust-analyzer cargo syntect 5.3.0 highlighting/style/impl#[FontStyle]BOLD., |
| 1029 |
}; |
| 1030 |
} |
| 1031 |
lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! { |
| 1032 |
static ref SYNTAX_HIGHLIGHTED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_HIGHLIGHTED_STYLE#: Stylerust-analyzer cargo git-delta 0.19.2 style/Style# = Stylerust-analyzer cargo git-delta 0.19.2 style/Style# { |
| 1033 |
ansi_term_stylerust-analyzer cargo git-delta 0.19.2 style/Style#ansi_term_style.: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style# { |
| 1034 |
foregroundrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#foreground.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo nu-ansi-term 0.50.3 style/Color#::Whiterust-analyzer cargo nu-ansi-term 0.50.3 style/Color#White#), |
| 1035 |
backgroundrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#background.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo nu-ansi-term 0.50.3 style/Color#::Whiterust-analyzer cargo nu-ansi-term 0.50.3 style/Color#White#), |
| 1036 |
is_underlinerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#is_underline.: true, |
| 1037 |
..ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#::newrust-analyzer cargo nu-ansi-term 0.50.3 style/impl#[Style]new().() |
| 1038 |
}, |
| 1039 |
is_emphrust-analyzer cargo git-delta 0.19.2 style/Style#is_emph.: false, |
| 1040 |
is_omittedrust-analyzer cargo git-delta 0.19.2 style/Style#is_omitted.: false, |
| 1041 |
is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw.: false, |
| 1042 |
is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted.: true, |
| 1043 |
decoration_stylerust-analyzer cargo git-delta 0.19.2 style/Style#decoration_style.: DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::NoDecorationrust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#NoDecoration#, |
| 1044 |
}; |
| 1045 |
} |
| 1046 |
lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! { |
| 1047 |
static ref NON_SYNTAX_HIGHLIGHTED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/NON_SYNTAX_HIGHLIGHTED_STYLE#: Stylerust-analyzer cargo git-delta 0.19.2 style/Style# = Stylerust-analyzer cargo git-delta 0.19.2 style/Style# { |
| 1048 |
ansi_term_stylerust-analyzer cargo git-delta 0.19.2 style/Style#ansi_term_style.: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style# { |
| 1049 |
foregroundrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#foreground.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo nu-ansi-term 0.50.3 style/Color#::Whiterust-analyzer cargo nu-ansi-term 0.50.3 style/Color#White#), |
| 1050 |
backgroundrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#background.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo nu-ansi-term 0.50.3 style/Color#::Whiterust-analyzer cargo nu-ansi-term 0.50.3 style/Color#White#), |
| 1051 |
is_underlinerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#is_underline.: true, |
| 1052 |
..ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#::newrust-analyzer cargo nu-ansi-term 0.50.3 style/impl#[Style]new().() |
| 1053 |
}, |
| 1054 |
is_emphrust-analyzer cargo git-delta 0.19.2 style/Style#is_emph.: false, |
| 1055 |
is_omittedrust-analyzer cargo git-delta 0.19.2 style/Style#is_omitted.: false, |
| 1056 |
is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw.: false, |
| 1057 |
is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted.: false, |
| 1058 |
decoration_stylerust-analyzer cargo git-delta 0.19.2 style/Style#decoration_style.: DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::NoDecorationrust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#NoDecoration#, |
| 1059 |
}; |
| 1060 |
} |
| 1061 |
lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! { |
| 1062 |
static ref SUPERIMPOSED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SUPERIMPOSED_STYLE#: Stylerust-analyzer cargo git-delta 0.19.2 style/Style# = Stylerust-analyzer cargo git-delta 0.19.2 style/Style# { |
| 1063 |
ansi_term_stylerust-analyzer cargo git-delta 0.19.2 style/Style#ansi_term_style.: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style# { |
| 1064 |
foregroundrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#foreground.: to_ansi_colorrust-analyzer cargo git-delta 0.19.2 utils/bat/terminal/to_ansi_color().(SyntectColorrust-analyzer cargo syntect 5.3.0 highlighting/style/Color#::BLACKrust-analyzer cargo syntect 5.3.0 highlighting/style/impl#[Color]BLACK., true), |
| 1065 |
backgroundrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#background.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo nu-ansi-term 0.50.3 style/Color#::Whiterust-analyzer cargo nu-ansi-term 0.50.3 style/Color#White#), |
| 1066 |
is_underlinerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#is_underline.: true, |
| 1067 |
..ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#::newrust-analyzer cargo nu-ansi-term 0.50.3 style/impl#[Style]new().() |
| 1068 |
}, |
| 1069 |
is_emphrust-analyzer cargo git-delta 0.19.2 style/Style#is_emph.: false, |
| 1070 |
is_omittedrust-analyzer cargo git-delta 0.19.2 style/Style#is_omitted.: false, |
| 1071 |
is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw.: false, |
| 1072 |
is_syntax_highlightedrust-analyzer cargo git-delta 0.19.2 style/Style#is_syntax_highlighted.: true, |
| 1073 |
decoration_stylerust-analyzer cargo git-delta 0.19.2 style/Style#decoration_style.: DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::NoDecorationrust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#NoDecoration#, |
| 1074 |
}; |
| 1075 |
} |
| 1076 |
|
| 1077 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1078 |
fn test_superimpose_style_sections_1rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/test_superimpose_style_sections_1().() { |
| 1079 |
let sections_1 = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_STYLE][Deref]deref().SYNTAX_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_STYLE., "ab")]; |
| 1080 |
let sections_2 = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_HIGHLIGHTED_STYLE][Deref]deref().SYNTAX_HIGHLIGHTED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_HIGHLIGHTED_STYLE., "ab")]; |
| 1081 |
let superimposed = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SUPERIMPOSED_STYLE][Deref]deref().SUPERIMPOSED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SUPERIMPOSED_STYLE., "ab".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())]; |
| 1082 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1083 |
superimpose_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/superimpose_style_sections().(§ions_1, §ions_2, true, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#::defaultrust-analyzer cargo syntect 5.3.0 highlighting/style/impl#[Style][Default]default().()), |
| 1084 |
superimposed |
| 1085 |
); |
| 1086 |
} |
| 1087 |
|
| 1088 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1089 |
fn test_superimpose_style_sections_2rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/test_superimpose_style_sections_2().() { |
| 1090 |
let sections_1 = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_STYLE][Deref]deref().SYNTAX_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_STYLE., "ab")]; |
| 1091 |
let sections_2 = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 1092 |
(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_HIGHLIGHTED_STYLE][Deref]deref().SYNTAX_HIGHLIGHTED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_HIGHLIGHTED_STYLE., "a"), |
| 1093 |
(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_HIGHLIGHTED_STYLE][Deref]deref().SYNTAX_HIGHLIGHTED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_HIGHLIGHTED_STYLE., "b"), |
| 1094 |
]; |
| 1095 |
let superimposed = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SUPERIMPOSED_STYLE][Deref]deref().SUPERIMPOSED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SUPERIMPOSED_STYLE., Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("ab"))]; |
| 1096 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1097 |
superimpose_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/superimpose_style_sections().(§ions_1, §ions_2, true, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#::defaultrust-analyzer cargo syntect 5.3.0 highlighting/style/impl#[Style][Default]default().()), |
| 1098 |
superimposed |
| 1099 |
); |
| 1100 |
} |
| 1101 |
|
| 1102 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1103 |
fn test_superimpose_style_sections_3rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/test_superimpose_style_sections_3().() { |
| 1104 |
let sections_1 = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_STYLE][Deref]deref().SYNTAX_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_STYLE., "ab")]; |
| 1105 |
let sections_2 = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[NON_SYNTAX_HIGHLIGHTED_STYLE][Deref]deref().NON_SYNTAX_HIGHLIGHTED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/NON_SYNTAX_HIGHLIGHTED_STYLE., "ab")]; |
| 1106 |
let superimposed = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[NON_SYNTAX_HIGHLIGHTED_STYLE][Deref]deref().NON_SYNTAX_HIGHLIGHTED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/NON_SYNTAX_HIGHLIGHTED_STYLE., "ab".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())]; |
| 1107 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1108 |
superimpose_style_sectionsrust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/superimpose_style_sections().(§ions_1, §ions_2, true, SyntectStylerust-analyzer cargo syntect 5.3.0 highlighting/style/Style#::defaultrust-analyzer cargo syntect 5.3.0 highlighting/style/impl#[Style][Default]default().()), |
| 1109 |
superimposed |
| 1110 |
); |
| 1111 |
} |
| 1112 |
|
| 1113 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1114 |
fn test_exploderust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/test_explode().() { |
| 1115 |
let arbitrary = 0; |
| 1116 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1117 |
exploderust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/explode().(&[(arbitrary, "ab")]), |
| 1118 |
vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(arbitrary, 'a'), (arbitrary, 'b')] |
| 1119 |
) |
| 1120 |
} |
| 1121 |
|
| 1122 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1123 |
fn test_superimposerust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/test_superimpose().() { |
| 1124 |
let x = (*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_STYLE][Deref]deref().SYNTAX_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_STYLE., 'a'); |
| 1125 |
let pairs = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(&x, (*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_HIGHLIGHTED_STYLE][Deref]deref().SYNTAX_HIGHLIGHTED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_HIGHLIGHTED_STYLE., 'a'))]; |
| 1126 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1127 |
superimposerust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/superimpose().(pairs), |
| 1128 |
vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![((*rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_STYLE][Deref]deref().SYNTAX_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_STYLE., *rust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/impl#[SYNTAX_HIGHLIGHTED_STYLE][Deref]deref().SYNTAX_HIGHLIGHTED_STYLErust-analyzer cargo git-delta 0.19.2 paint/superimpose_style_sections/tests/SYNTAX_HIGHLIGHTED_STYLE.), 'a')] |
| 1129 |
); |
| 1130 |
} |
| 1131 |
} |
| 1132 |
} |