mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
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.
This commit is contained in:
1 parent
a6b4d29801
commit
cc51cd4de1
1 file changed
+4
-5
@@ -54,12 +54,11 @@ pub fn source(st: &DocState) -> Option<HistorySource> {
|
||||
// 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).
|
||||
|
||||
Reference in new issue
Block a user