PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
M9: stop the side-by-side frame as soon as either half has closed (#3915)
mtlcl4104ac31b3ffed5
diff --git a/crates/ui-egui/src/compare_ui.rs b/crates/ui-egui/src/compare_ui.rsindex ad034d402..afc961e78 100644--- a/crates/ui-egui/src/compare_ui.rs+++ b/crates/ui-egui/src/compare_ui.rs@@ -338,8 +338,10 @@ pub(crate) fn compare_area(app: &mut PdfCraftApp, old: usize, new: usize, ui: &mlet ids = [app.views[old].id, app.views[new].id];let find = |app: &PdfCraftApp, id| app.views.iter().position(|v| v.id == id);ui.painter().vline(rect.min.x + half_w, rect.y_range(), egui::Stroke::new(gap, t.border));- for (k, (r, id)) in [(left, ids[0]), (right, ids[1])].into_iter().enumerate() {- let Some(index) = find(app, id) else { return };+ for (k, r) in [left, right].into_iter().enumerate() {+ // Both halves must still be open: once either has closed, the pair is over.+ let (Some(old_index), Some(new_index)) = (find(app, ids[0]), find(app, ids[1])) else { return };+ let index = if k == 0 { old_index } else { new_index };let caption = egui::Rect::from_min_size(r.min, egui::vec2(r.width(), caption_h));ui.painter().rect_filled(caption, 0.0, t.panel);let label = crate::i18n::fmt(if k == 0 { tl!("Old file: {name}") } else { tl!("New file: {name}") }, &[("name", &names[k])]);