Fix: sketch edit exit (double-click a sketch no longer traps you)
Edit Sketch rolls the timeline back to just after the sketch and faces it; Finish Sketch, Esc (once nothing else is left to cancel) and editing another feature all leave it, restoring the marker and the previous view. Editing the open sketch again is a no-op and editing another sketch switches cleanly. The control channel's ui.click takes double: true. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
1 parent
73f68f3f50
commit
71a1903122
6 files changed
+138
-12
No files matched your search
@@ -0,0 +1,71 @@
|
||||
//! Regression tests: editing a sketch from the Browser or timeline can always be left again.
|
||||
|
||||
use crate::{Services, SolveApp};
|
||||
use solvecraft_engine::Session;
|
||||
use solvecraft_engine::doc::FeatureKind;
|
||||
|
||||
fn sample_app() -> SolveApp {
|
||||
let mut s = Session::default();
|
||||
s.run_script(&solvecraft_engine::sample::script()).unwrap();
|
||||
SolveApp::new(s, Services::default())
|
||||
}
|
||||
|
||||
fn first_sketch(app: &SolveApp) -> u64 {
|
||||
app.session.doc.features.iter().find(|f| matches!(f.kind, FeatureKind::Sketch { .. })).map(|f| f.id).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn edit_sketch_rolls_back_and_finish_restores() {
|
||||
let mut app = sample_app();
|
||||
let marker = app.session.doc.marker;
|
||||
let id = first_sketch(&app);
|
||||
app.edit_sketch(id);
|
||||
assert_eq!(app.session.active_sketch, Some(id));
|
||||
let idx = app.session.doc.feature_index(id).unwrap();
|
||||
assert_eq!(app.session.doc.marker, Some(idx + 1), "later features are rolled back");
|
||||
app.finish_sketch();
|
||||
assert_eq!(app.session.active_sketch, None);
|
||||
assert_eq!(app.session.doc.marker, marker, "marker restored");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn editing_twice_does_not_nest() {
|
||||
let mut app = sample_app();
|
||||
let marker = app.session.doc.marker;
|
||||
let id = first_sketch(&app);
|
||||
app.edit_sketch(id);
|
||||
app.edit_sketch(id);
|
||||
app.edit_feature(id);
|
||||
app.finish_sketch();
|
||||
assert_eq!(app.session.active_sketch, None);
|
||||
assert_eq!(app.session.doc.marker, marker);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn editing_another_sketch_switches_cleanly() {
|
||||
let mut app = sample_app();
|
||||
let marker = app.session.doc.marker;
|
||||
let ids: Vec<u64> = app.session.doc.features.iter().filter(|f| matches!(f.kind, FeatureKind::Sketch { .. })).map(|f| f.id).collect();
|
||||
app.edit_sketch(ids[0]);
|
||||
app.edit_sketch(ids[1]);
|
||||
assert_eq!(app.session.active_sketch, Some(ids[1]));
|
||||
app.finish_sketch();
|
||||
assert_eq!(app.session.active_sketch, None);
|
||||
assert_eq!(app.session.doc.marker, marker);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn toolbar_finish_and_other_feature_edit_leave_the_sketch() {
|
||||
let mut app = sample_app();
|
||||
let marker = app.session.doc.marker;
|
||||
let id = first_sketch(&app);
|
||||
app.edit_sketch(id);
|
||||
app.start("SketchStop");
|
||||
assert_eq!(app.session.active_sketch, None);
|
||||
assert_eq!(app.session.doc.marker, marker);
|
||||
// Double-clicking a solid feature while sketching finishes the sketch first.
|
||||
app.edit_sketch(id);
|
||||
let extrude = app.session.doc.features.iter().find(|f| !matches!(f.kind, FeatureKind::Sketch { .. })).map(|f| f.id).unwrap();
|
||||
app.edit_feature(extrude);
|
||||
assert_eq!(app.session.active_sketch, None);
|
||||
}
|
||||
Reference in new issue
Block a user