From 4ac31b3ffed5622eb01758b9fc41e23ac06ea4f3 Mon Sep 17 00:00:00 2001 From: mtlcl410 <2368091+mtlcl410@users.noreply.github.com> Date: Thu, 22 Oct 2026 05:07:42 +0800 Subject: [PATCH] M9: stop the side-by-side frame as soon as either half has closed (#3915) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01R3niW7kVeT8mi7TpWc8eAJ --- crates/ui-egui/src/compare_ui.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/compare_ui.rs b/crates/ui-egui/src/compare_ui.rs index 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: &m let 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])]);