Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

Open Recent: focus an already-open file through the shared lookup (#1620)

Eduardo Soaresa5e16bf55689
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index f34fd63de..d7f33abbc 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);
+ }
}
}