Preserve read-only panning while canceling State edits

This commit is contained in:
2026-09-22 21:21:50 -07:00
parent 26979c1093
commit b8685416f5
3 changed files with 25 additions and 2 deletions
@@ -305,7 +305,16 @@ fn state_bend_self_loop_add_move_remove_clear_preserves_project_and_source_histo
vec![],
);
assert_eq!(app.project(), &baseline.decoded.project);
assert_source_model_agree(&app);
// Clear is a new source-preserving edit and may retain empty-list trivia.
// Exact original bytes are restored by history, not by reauthoring a value.
for _ in 0..3 {
assert!(app.document.can_undo());
send(&mut app, Message::Undo);
}
assert_eq!(app.project(), &baseline.decoded.project);
assert_eq!(app.document.bundle(), &baseline.bundle);
assert!(!app.document.can_undo());
}
#[test]
@@ -136,13 +136,16 @@ enum Hit {
}
impl State {
fn cancel_gesture(&mut self) {
fn cancel_edit(&mut self) {
self.press = None;
self.preview = None;
self.attachment_preview = None;
self.bend = None;
self.bend_preview = None;
self.attachment_viewport = None;
}
fn cancel_gesture(&mut self) {
self.cancel_edit();
self.pan_from = None;
}
fn reset(&mut self) {
@@ -1178,7 +1181,9 @@ impl canvas::Program<Event> for StateCanvas<'_> {
state.tool = Some(self.tool);
}
if !self.editable {
state.cancel_gesture();
// Pending edits block model changes, but read-only panning remains
// available and must survive successive pointer events.
state.cancel_edit();
state.source = None;
}
if state