History: the sketch at the marker is shown while it's the current step (#5202) (#5204)

* claim: #5202

* History: show the sketch at the marker while it's the current step (#5202)

A sketch a later feature uses is hidden, so moving the History marker
onto it changed nothing in the view. The sketch immediately before the
marker is now drawn even when consumed or hidden; its stored visibility
is untouched, and earlier sketches, hidden components, groups and the
Sketches folder still apply.
This commit is contained in:
raykholo
2026-10-24 21:12:11 +00:00
committed by GitHub
parent fcc3753a4c
commit ab889a8fff
2 changed files with 46 additions and 4 deletions
+16 -4
View File
@@ -638,15 +638,27 @@ impl SectionIndex {
}
}
/// Is a sketch drawn? The sketch being edited always is; otherwise not when hidden, nor in a
/// hidden component, Sketches folder or group (even one shown on its own), and one used by a
/// feature only when shown on its own.
/// Is a sketch drawn? The sketch being edited always is; otherwise not in a hidden component,
/// Sketches folder or group (even one shown on its own). The sketch immediately before a
/// rollback marker is shown regardless of its individual visibility; other hidden sketches, and
/// ones used by a feature unless shown on their own, retain their stored visibility.
pub fn sketch_shown(s: &Session, id: u64) -> bool {
let v = &s.visibility;
if s.active_sketch == Some(id) {
return true;
}
if v.hidden_sketches.contains(&id) || !sketch_component_visible(s, id) || s.feature_folder_hidden(id, "sketches") {
if !sketch_component_visible(s, id) || s.feature_folder_hidden(id, "sketches") {
return false;
}
if s.doc
.marker
.and_then(|position| position.checked_sub(1))
.and_then(|index| s.doc.features.get(index))
.is_some_and(|f| f.id == id && matches!(f.kind, solidcraft_doc::FeatureKind::Sketch { .. }))
{
return true;
}
if v.hidden_sketches.contains(&id) {
return false;
}
v.shown_sketches.contains(&id) || !sketch_consumed(s, id)
+30
View File
@@ -5399,6 +5399,36 @@ mod tests {
}
}
#[test]
fn history_marker_shows_only_its_sketch_without_changing_visibility() -> Result<(), Box<dyn std::error::Error>> {
for explicitly_hidden in [false, true] {
let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());
app.ui.show_grid = false;
let mut sketches = Vec::new();
for (name, x) in [("First", 0), ("Second", 30)] {
app.run("sketch.create", json!({"plane":"XY","name":name}))?;
app.run("sketch.rectangle.two_point", json!({"p0":[x,0],"p1":[x+10,10]}))?;
app.run("sketch.finish", json!({}))?;
let id = app.session.doc.find_feature(name).ok_or("missing sketch")?.id;
sketches.push(id);
app.run("solid.extrude", json!({"sketch":name,"distance":5,"body_name":name}))?;
}
if explicitly_hidden {
app.session.visibility.hidden_sketches.clone_from(&sketches);
}
let stored = app.session.visibility.clone();
let rect = Rect::from_min_size(Pos2::ZERO, vec2(640., 480.));
for (position, expected) in [(0, None), (1, sketches.first().copied()), (2, None), (3, sketches.get(1).copied()), (4, None)] {
app.run("timeline.roll_to", json!({"position":position}))?;
assert_eq!(visible_sketches(&app), expected.into_iter().collect::<Vec<_>>(), "position {position}, hidden {explicitly_hidden}");
let scene = build_sketch_scene(&app, &projection(&app, rect)).merged();
assert_eq!(!scene.lines.is_empty(), expected.is_some(), "sketch lines at position {position}");
assert_eq!(app.session.visibility, stored, "stepping must preserve stored visibility");
}
}
Ok(())
}
#[test]
fn timeline_modifier_highlight_follows_edits_and_rollback() {
let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());