mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-03 09:10:33 +00:00
Open Recent: focus an already-open file through the shared lookup (#1620)
Co-authored-by: GLM <noreply@z.ai>
This commit is contained in:
1 parent
95a769eedc
commit
a5e16bf556
1 file changed
+7
-5
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user