From cc51cd4de1da0d2f615b985bc9dbdf119df07da6 Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Thu, 26 Nov 2026 20:41:12 +0100 Subject: [PATCH] fix(history): follow the history when it moves the source record While a state source is set the history keeps the answer: a source state deleted or discarded leaves no source (#2966), Clear History holds it back until its undo, and an action folding its steps renames the row (#3536). Reading the recorded id first and the history's own row second follows all three, instead of only the two the panel does directly. --- crates/engine-core/src/cmd/history_source_cmds.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/engine-core/src/cmd/history_source_cmds.rs b/crates/engine-core/src/cmd/history_source_cmds.rs index 80e5347f82..2b5ee6c5c2 100644 --- a/crates/engine-core/src/cmd/history_source_cmds.rs +++ b/crates/engine-core/src/cmd/history_source_cmds.rs @@ -54,12 +54,11 @@ pub fn source(st: &DocState) -> Option { // A state set in the panel is kept by its state id: it stays the source while older states fall // off and is gone once it is deleted or discarded (#2966). ops' // [`photocraft_ops::History::brush_source`] reads row 0 both for such a set state and for "none - // set", so the choice is recorded here in `source_state_id` (#12845). + // set", so the choice is recorded here in `source_state_id` (#12845). While a state source is + // set, ops keeps the answer: Clear History holds it back until its undo, and an action folding + // its steps can rename the row (#3536). if let Some(id) = st.source_state_id { - // Clear History holds a set source back with the states it took off: until its undo, the - // current state is the source, as before (#3536). - let row = if st.history.is_cleared() { st.history.brush_source() } else { st.history.row_of(id) }; - return row.map(HistorySource::State); + return st.history.row_of(id).or_else(|| st.history.brush_source()).map(HistorySource::State); } match st.open_snapshot { // The document as opened outlives the states, so a click still restores it (#12618).