diff --git a/crates/snowbound/src/main.rs b/crates/snowbound/src/main.rs index f4b1e76a06fa8a1a1d6639fcc3e3ad42cbb5b1b8..9f2bb2cabf81c4a0efed2a253546f0042517d3b8 100644 --- a/crates/snowbound/src/main.rs +++ b/crates/snowbound/src/main.rs @@ -3732,21 +3732,23 @@ impl State { return Ok(()); } // A section opens from its file once: a load already opening it shows it here, - // and a parked pane that asked for it first leaves it to this one. + // and a parked pane that asked for it first, if any still waits, leaves it to + // this one. let opening = (self.opening_files.iter()) - .find(|(_, opening)| *opening == key) + .rfind(|(_, opening)| *opening == key) .map(|(request, _)| *request); - if opening == Some(self.pane.loading) { - return Ok(()); - } - let asked = - (self.parked.iter()).position(|parked| Some(parked.pane.loading) == opening); - if let Some(at) = asked { - let fresh = self.request(); - let pane = &mut self.parked[at].pane; - let (request, opened) = (pane.loading, pane.opening.take()); - (pane.loading, pane.switching) = (fresh, None); - (self.pane.loading, self.pane.opening) = (request, opened); + if let Some(request) = opening { + if request != self.pane.loading { + let fresh = self.request(); + let asked = (self.parked.iter_mut()) + .map(|parked| &mut parked.pane) + .find(|pane| pane.loading == request); + let opened = asked.and_then(|pane| { + (pane.loading, pane.switching) = (fresh, None); + pane.opening.take() + }); + (self.pane.loading, self.pane.opening) = (request, opened); + } return Ok(()); } let notify = notify(self.proxy.clone()); @@ -3983,8 +3985,8 @@ impl State { } /// Does `operation`, an edit of the open section's pages `spaces` or its list without - /// any, then shows it in every pane on the section and runs `then` if that is still the - /// open one. + /// any, then shows it in every pane on the section and runs `then` in the pane that asked, + /// wherever the focus is, while that pane still shows the section. fn section_edit< T: Send + 'static, F: Future> + Send + 'static, @@ -3994,18 +3996,22 @@ impl State { operation: F, then: impl FnOnce(&mut State, T) -> Result<(), Box> + Send + 'static, ) -> Result<(), Box> { - let key = self.session.as_ref().ok_or("No section is open")?.key(); + let (key, asker) = ( + self.session.as_ref().ok_or("No section is open")?.key(), + self.pane.id, + ); self.complete_async(operation, move |state, result| { let value = result?; state.edited_sections(&key, spaces, |shown| shown == key); - if state - .session - .as_ref() - .is_some_and(|session| session.key() == key) - { - then(state, value) - } else { - Ok(()) + // What follows is the asking pane's, while it still shows the section. + let then = move |state: &mut State| match &state.session { + Some(session) if session.key() == key => then(state, value), + _ => Ok(()), + }; + match (state.parked.iter()).position(|parked| parked.pane.id == asker) { + Some(at) => state.in_pane(at, then), + None if state.pane.id == asker => then(state), + None => Ok(()), } }) } diff --git a/crates/snowbound/src/split.rs b/crates/snowbound/src/split.rs index 42ebec0c67cec43cbdc31df2d3350872ce2fcdbf..67458d6c1baf62346847fca3fde67b2cb6178527 100644 --- a/crates/snowbound/src/split.rs +++ b/crates/snowbound/src/split.rs @@ -178,10 +178,13 @@ impl State { } let old = Some(session.key()); let identity = (session.library).section_identity(&session.tabs[session.tab].path); + // A section deleted lies in the recycle bin, where a pane doesn't follow it. + let binned = crate::recycle::binned(&session.tabs[session.tab].path); let path = library.catalog().and_then(|catalog| { (catalog.sections()) .find(|section| Some(section.file_id) == identity) .map(|section| section.path.clone()) + .filter(|path| binned || !crate::recycle::binned(path)) }); match path.map(|path| session.follow(Arc::clone(library), &path)) { Some(Ok(())) => {