From a5e16bf556896f9d6ae435f18f29feccf7929c4a Mon Sep 17 00:00:00 2001 From: Eduardo Soares Date: Mon, 12 Oct 2026 23:12:13 -0300 Subject: [PATCH] Open Recent: focus an already-open file through the shared lookup (#1620) Co-authored-by: GLM --- crates/ui-egui/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index f34fd63ded..d7f33abbc2 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1200,11 +1200,13 @@ impl PdfCraftApp { /// Open a file from a recent list: focus the tab already showing it, else open it (File ▸ /// Open Recent and the Home view's list share this). pub fn open_recent(&mut self, path: &str) { - if let Some(i) = self.views.iter().position(|v| self.session.get(v.id).and_then(|d| d.path.as_deref()) == Some(path)) { - self.active = Some(i); - } else { - #[cfg(not(target_arch = "wasm32"))] - self.open_path(path); + #[cfg(not(target_arch = "wasm32"))] + { + if let Some(i) = self.view_showing(path) { + self.active = Some(i); + } else { + self.open_path(path); + } } }