more re-use in diffs
[?]
May 7, 2025, 5:55 PM
UUB7SHLRIPT6JKE64MHEJBFCS5FHH5SN5R2OOK7TR2NVCPB6VN7ACDependencies
- [2]
MJDGPSHGWIP contents diff - [3]
ZVI4AWERwoot contents_diff - [4]
QMAUTRB6refactor diff - [5]
DCSUCH6Radd undecoded diff view, improve decoded view style - [6]
O7PQIOJ3add missing undecoded diffs views
Change contents
- replacement in crates/inflorescence/src/diff.rs at line 185
without.push(DiffWithoutContents::Move);without.push(DiffWithoutContents::SolveNameConflict); - replacement in crates/inflorescence/src/diff.rs at line 188
without.push(DiffWithoutContents::Move);without.push(DiffWithoutContents::UnsolveNameConflict); - replacement in crates/inflorescence/src/diff.rs at line 406[2.10916]→[5.445:478](∅→∅),[5.478]→[2.11010:11131](∅→∅),[3.28438]→[2.11010:11131](∅→∅),[2.11010]→[2.11010:11131](∅→∅),[2.11131]→[5.479:559](∅→∅),[5.559]→[2.11131:11297](∅→∅),[2.11131]→[2.11131:11297](∅→∅),[2.11297]→[5.560:655](∅→∅),[5.655]→[2.11432:11483](∅→∅),[2.11432]→[2.11432:11483](∅→∅),[2.11483]→[5.656:814](∅→∅),[5.814]→[2.11624:11717](∅→∅),[2.11624]→[2.11624:11717](∅→∅)
let sections_view = combined.sections.iter().flat_map(|section| match section {Section::Unchanged(lines) => {// TODO avoid collecting by placing these into `column` in herelet res = lines.iter().enumerate().map(|(ix, line)| {el(row([el(code_view(" ")),el(line_num_view(current_line + ix,line_num_digits,)),el(code_view(line.clone()).width(Length::Fill)),]))}).collect::<Vec<_>>();let sections_view = combined.sections.iter().map(|section| match section {Section::Unchanged(lines) => {let res = lines.iter().enumerate().map(move |(ix, line)| {line_view(LineKind::Unchanged,current_line + ix,line_num_digits,line,)}); - replacement in crates/inflorescence/src/diff.rs at line 417[2.11718]→[2.11718:11985](∅→∅),[2.11985]→[5.815:953](∅→∅),[5.953]→[2.12153:12204](∅→∅),[2.12153]→[2.12153:12204](∅→∅),[2.12204]→[5.954:1112](∅→∅),[5.1112]→[2.12345:12373](∅→∅),[2.12345]→[2.12345:12373](∅→∅),[2.12373]→[5.1113:1332](∅→∅),[5.1332]→[2.12373:12467](∅→∅),[2.12373]→[2.12373:12467](∅→∅),[2.12467]→[5.1333:1471](∅→∅),[5.1471]→[2.12635:12686](∅→∅),[2.12635]→[2.12635:12686](∅→∅),[2.12686]→[5.1472:1630](∅→∅),[5.1630]→[2.12827:12855](∅→∅),[2.12827]→[2.12827:12855](∅→∅),[2.12855]→[5.1631:1848](∅→∅),[5.1848]→[2.12855:12921](∅→∅),[2.12855]→[2.12855:12921](∅→∅)
current_line += lines.len();res}Section::Changed { deleted, added } => {let res = deleted.iter().enumerate().map(|(ix, line)| {el(container(row([el(code_view("- ")),el(line_num_view(current_line + ix,line_num_digits,)),el(code_view(line.clone()).width(Length::Fill)),])).style(|_theme| {container::background(Background::from(DELETED_BG_COLOR,))}))}).chain(added.iter().enumerate().map(|(ix, line)| {el(container(row([el(code_view("+ ")),el(line_num_view(current_line + ix,line_num_digits,)),el(code_view(line.clone()).width(Length::Fill)),])).style(|_theme| {container::background(Background::from(ADDED_BG_COLOR,))}))})).collect::<Vec<_>>();current_line += lines.len();el(column(res))}Section::Changed { deleted, added } => {let res = deleted.iter().enumerate().map(move |(ix, line)| {line_view(LineKind::Deleted,current_line + ix,line_num_digits,line,)}).chain(added.iter().enumerate().map(move |(ix, line)| {line_view(LineKind::Added,current_line + ix,line_num_digits,line,)})); - replacement in crates/inflorescence/src/diff.rs at line 441
current_line += added.len();res}}).collect::<Vec<_>>();current_line += added.len();el(column(res))}}); - replacement in crates/inflorescence/src/diff.rs at line 496
let lines_view = lines.iter().enumerate().map(|(ix, line)| {el(row([el(code_view(if *deleted { "- " } else { "+ " })),el(line_num_view(line_num + ix, line_num_digits)),el(code_view(line.clone()).width(Length::Fill)),]))let lines_view = lines.into_iter().enumerate().map(|(ix, line)| {line_view(if *deleted {LineKind::Deleted} else {LineKind::Added},line_num + ix,line_num_digits,line,) - edit in crates/inflorescence/src/diff.rs at line 522
// TODO: re-use with `view_decoded` - replacement in crates/inflorescence/src/diff.rs at line 523
.iter().into_iter() - replacement in crates/inflorescence/src/diff.rs at line 526
el(container(row([el(code_view("- ")),el(line_num_view(line_num + ix, line_num_digits)),el(code_view(line.clone()).width(Length::Fill)),])).style(|_theme| {container::background(Background::from(DELETED_BG_COLOR,))}))line_view(LineKind::Deleted,line_num + ix,line_num_digits,line,) - replacement in crates/inflorescence/src/diff.rs at line 533
.chain(replacement_lines.iter().enumerate().map(.chain(replacement_lines.into_iter().enumerate().map( - replacement in crates/inflorescence/src/diff.rs at line 535
el(container(row([el(code_view("+ ")),el(line_num_view(line_num + ix, line_num_digits)),el(code_view(line.clone()).width(Length::Fill)),])).style(|_theme| {container::background(Background::from(ADDED_BG_COLOR,))}))line_view(LineKind::Added,line_num + ix,line_num_digits,line,) - replacement in crates/inflorescence/src/diff.rs at line 579
el(row([el(code_view(if *deleted { "- " } else { "+ " })),el(line_num_view(line_num, 1)),el(code_view(line).width(Length::Fill)),]))line_view(if *deleted {LineKind::Deleted} else {LineKind::Added},line_num,1,line,) - replacement in crates/inflorescence/src/diff.rs at line 601
el(row([el(code_view("- ")),el(line_num_view(line_num, 1)),el(code_view(change_line).width(Length::Fill)),])),el(row([el(code_view("+ ")),el(line_num_view(line_num, 1)),el(code_view(replacement_line).width(Length::Fill)),])),line_view(LineKind::Deleted, line_num, 1, change_line),line_view(LineKind::Added, line_num, 1, replacement_line), - replacement in crates/inflorescence/src/diff.rs at line 608
fn code_view<'a>(txt: impl text::IntoFragment<'a>) -> iced::widget::Text<'a> {fn mono_text<'a>(txt: impl text::IntoFragment<'a>) -> iced::widget::Text<'a> { - replacement in crates/inflorescence/src/diff.rs at line 615
code_view(txt).font(Font::MONOSPACE).style(move |theme| {mono_text(txt).font(Font::MONOSPACE).style(move |theme| { - edit in crates/inflorescence/src/diff.rs at line 622[5.6791]
#[derive(Debug, Clone, Copy)]enum LineKind {Unchanged,Added,Deleted,}fn line_view<'a>(kind: LineKind,line_num: usize,line_num_digits: usize,line: impl text::IntoFragment<'a>,) -> Element<'a, Action> {let line = container(row([el(mono_text(match kind {LineKind::Unchanged => " ",LineKind::Added => "+ ",LineKind::Deleted => "- ",})),el(line_num_view(line_num, line_num_digits)),el(mono_text(line).width(Length::Fill)),]));el(match kind {LineKind::Unchanged => line,LineKind::Added => line.style(|_theme| {container::background(Background::from(ADDED_BG_COLOR))}),LineKind::Deleted => line.style(|_theme| {container::background(Background::from(DELETED_BG_COLOR))}),})}