| ... | ... | @@ -3847,6 +3847,35 @@ impl State { |
| 3847 | 3847 | } |
| 3848 | 3848 | lap("switch pictures", opening.since); |
| 3849 | 3849 | let requested = opening.requested; |
| 3850 | if let Shown::Section(session) | Shown::Created(session) = &mut opening.loaded |
| 3851 | && let Some(library) = self |
| 3852 | .notebooks |
| 3853 | .iter() |
| 3854 | .find(|listed| { |
| 3855 | listed.location == session.library.location |
| 3856 | && Arc::ptr_eq(&listed.structure, &session.library.structure) |
| 3857 | && !Arc::ptr_eq(listed, &session.library) |
| 3858 | }) |
| 3859 | .cloned() |
| 3860 | { |
| 3861 | let identity = session |
| 3862 | .library |
| 3863 | .section_identity(&session.tabs[session.tab].path); |
| 3864 | let path = library.catalog().and_then(|catalog| { |
| 3865 | catalog |
| 3866 | .sections() |
| 3867 | .find(|section| Some(section.file_id) == identity) |
| 3868 | .map(|section| section.path.clone()) |
| 3869 | }); |
| 3870 | if let Some(path) = path { |
| 3871 | session.follow(library, &path)?; |
| 3872 | } else if let Some(path) = library.first_section() { |
| 3873 | return self.apply(Command::OpenSection(library, path)); |
| 3874 | } else { |
| 3875 | self.switching = None; |
| 3876 | return self.adopt(library, None); |
| 3877 | } |
| 3878 | } |
| 3850 | 3879 | // A recording goes on the page it started on. |
| 3851 | 3880 | self.stop_recording(true)?; |
| 3852 | 3881 | // The page shown so far keeps what was typed while the next one loaded. |
| ... | ... | @@ -3869,35 +3898,7 @@ impl State { |
| 3869 | 3898 | } |
| 3870 | 3899 | let created = matches!(opening.loaded, Shown::Created(_)); |
| 3871 | 3900 | match opening.loaded { |
| 3872 | | Shown::Section(mut session) | Shown::Created(mut session) => { |
| 3873 | | if let Some(library) = self |
| 3874 | | .notebooks |
| 3875 | | .iter() |
| 3876 | | .find(|listed| { |
| 3877 | | listed.location == session.library.location |
| 3878 | | && Arc::ptr_eq(&listed.structure, &session.library.structure) |
| 3879 | | && !Arc::ptr_eq(listed, &session.library) |
| 3880 | | }) |
| 3881 | | .cloned() |
| 3882 | | { |
| 3883 | | let identity = session |
| 3884 | | .library |
| 3885 | | .section_identity(&session.tabs[session.tab].path); |
| 3886 | | let path = library.catalog().and_then(|catalog| { |
| 3887 | | catalog |
| 3888 | | .sections() |
| 3889 | | .find(|section| Some(section.file_id) == identity) |
| 3890 | | .map(|section| section.path.clone()) |
| 3891 | | }); |
| 3892 | | if let Some(path) = path { |
| 3893 | | session.follow(library, &path)?; |
| 3894 | | } else if let Some(path) = library.first_section() { |
| 3895 | | return self.apply(Command::OpenSection(library, path)); |
| 3896 | | } else { |
| 3897 | | self.switching = None; |
| 3898 | | return self.adopt(library, None); |
| 3899 | | } |
| 3900 | | } |
| 3901 | Shown::Section(session) | Shown::Created(session) => { |
| 3901 | 3902 | // The settings keep the notebook shown, not the section. |
| 3902 | 3903 | let other_notebook = self |
| 3903 | 3904 | .session |