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])]);