Fix to use correct source ranges
This also reduces cloning.
This commit is contained in:
@ -590,7 +590,7 @@ fn artifacts_to_update(
|
|||||||
responses: &FnvHashMap<Uuid, OkModelingCmdResponse>,
|
responses: &FnvHashMap<Uuid, OkModelingCmdResponse>,
|
||||||
current_plane_id: Option<Uuid>,
|
current_plane_id: Option<Uuid>,
|
||||||
_ast: &Node<Program>,
|
_ast: &Node<Program>,
|
||||||
_exec_artifacts: &IndexMap<ArtifactId, Artifact>,
|
exec_artifacts: &IndexMap<ArtifactId, Artifact>,
|
||||||
) -> Result<Vec<Artifact>, KclError> {
|
) -> Result<Vec<Artifact>, KclError> {
|
||||||
// TODO: Build path-to-node from artifact_command source range. Right now,
|
// TODO: Build path-to-node from artifact_command source range. Right now,
|
||||||
// we're serializing an empty array, and the TS wrapper fills it in with the
|
// we're serializing an empty array, and the TS wrapper fills it in with the
|
||||||
@ -827,48 +827,32 @@ fn artifacts_to_update(
|
|||||||
source_ranges: vec![range],
|
source_ranges: vec![range],
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
let extra_artifact = _exec_artifacts.values().find_map(|a| {
|
let extra_artifact = exec_artifacts.values().find(|a| {
|
||||||
if let Artifact::StartSketchOnFace { face_id: id, .. } = a {
|
if let Artifact::StartSketchOnFace { face_id: id, .. } = a {
|
||||||
if *id == face_id.0 {
|
*id == face_id.0
|
||||||
return Some(a.clone());
|
} else {
|
||||||
}
|
false
|
||||||
}
|
}
|
||||||
None
|
|
||||||
});
|
});
|
||||||
let sketch_on_face_source_range = extra_artifact.and_then(|a| match a {
|
let sketch_on_face_source_range = extra_artifact
|
||||||
Artifact::StartSketchOnFace { source_range, .. } => Some(source_range),
|
.and_then(|a| match a {
|
||||||
_ => None,
|
Artifact::StartSketchOnFace { source_range, .. } => Some(*source_range),
|
||||||
});
|
// TODO: If we didn't find it, it's probably a bug.
|
||||||
let mut wall_artifact = Wall {
|
_ => None,
|
||||||
id: face_id,
|
})
|
||||||
seg_id: curve_id,
|
.unwrap_or_default();
|
||||||
edge_cut_edge_ids: Vec::new(),
|
|
||||||
sweep_id: path.sweep_id.expect("Expected sweep_id to be Some"),
|
|
||||||
path_ids: Vec::new(),
|
|
||||||
face_code_ref: CodeRef {
|
|
||||||
range,
|
|
||||||
path_to_node: path_to_node.clone(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(sketch_on_face_source_range) = sketch_on_face_source_range {
|
return_arr.push(Artifact::Wall(Wall {
|
||||||
wall_artifact.face_code_ref = CodeRef {
|
|
||||||
range: sketch_on_face_source_range,
|
|
||||||
path_to_node: path_to_node.clone(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
let wall = Wall {
|
|
||||||
id: face_id,
|
id: face_id,
|
||||||
seg_id: curve_id,
|
seg_id: curve_id,
|
||||||
edge_cut_edge_ids: Vec::new(),
|
edge_cut_edge_ids: Vec::new(),
|
||||||
sweep_id: path_sweep_id,
|
sweep_id: path_sweep_id,
|
||||||
path_ids: vec![],
|
path_ids: Vec::new(),
|
||||||
face_code_ref: CodeRef {
|
face_code_ref: CodeRef {
|
||||||
range,
|
range: sketch_on_face_source_range,
|
||||||
path_to_node: path_to_node.clone(),
|
path_to_node: Vec::new(),
|
||||||
},
|
},
|
||||||
};
|
}));
|
||||||
return_arr.push(Artifact::Wall(wall));
|
|
||||||
let mut new_seg = seg.clone();
|
let mut new_seg = seg.clone();
|
||||||
new_seg.surface_id = Some(face_id);
|
new_seg.surface_id = Some(face_id);
|
||||||
return_arr.push(Artifact::Segment(new_seg));
|
return_arr.push(Artifact::Segment(new_seg));
|
||||||
@ -883,7 +867,7 @@ fn artifacts_to_update(
|
|||||||
let Some(face_id) = face.face_id.map(ArtifactId::new) else {
|
let Some(face_id) = face.face_id.map(ArtifactId::new) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let cap = face.clone().cap;
|
let cap = face.cap;
|
||||||
let path_sweep_id = path.sweep_id.ok_or_else(|| {
|
let path_sweep_id = path.sweep_id.ok_or_else(|| {
|
||||||
KclError::Internal(KclErrorDetails {
|
KclError::Internal(KclErrorDetails {
|
||||||
message:format!(
|
message:format!(
|
||||||
@ -892,39 +876,33 @@ fn artifacts_to_update(
|
|||||||
source_ranges: vec![range],
|
source_ranges: vec![range],
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
let extra_artifact = _exec_artifacts.values().find(|a| {
|
let extra_artifact = exec_artifacts.values().find(|a| {
|
||||||
if let Artifact::StartSketchOnFace { face_id: id, .. } = a {
|
if let Artifact::StartSketchOnFace { face_id: id, .. } = a {
|
||||||
*id == face_id.0
|
*id == face_id.0
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let sketch_on_face_source_range = extra_artifact.and_then(|a| match a {
|
let sketch_on_face_source_range = extra_artifact
|
||||||
Artifact::StartSketchOnFace { source_range, .. } => Some(source_range),
|
.and_then(|a| match a {
|
||||||
_ => None,
|
Artifact::StartSketchOnFace { source_range, .. } => Some(*source_range),
|
||||||
});
|
_ => None,
|
||||||
let mut cap_artifact = Cap {
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
return_arr.push(Artifact::Cap(Cap {
|
||||||
id: face_id,
|
id: face_id,
|
||||||
sub_type: match cap {
|
sub_type: match cap {
|
||||||
ExtrusionFaceCapType::Bottom => CapSubType::Start,
|
ExtrusionFaceCapType::Bottom => CapSubType::Start,
|
||||||
_ => CapSubType::End,
|
_ => CapSubType::End,
|
||||||
},
|
},
|
||||||
edge_cut_edge_ids: Vec::new(),
|
edge_cut_edge_ids: Vec::new(),
|
||||||
sweep_id: path.sweep_id.expect("Expected sweep_id to be Some"),
|
sweep_id: path_sweep_id,
|
||||||
path_ids: Vec::new(),
|
path_ids: Vec::new(),
|
||||||
face_code_ref: CodeRef {
|
face_code_ref: CodeRef {
|
||||||
range,
|
range: sketch_on_face_source_range,
|
||||||
path_to_node: path_to_node.clone(),
|
path_to_node: Vec::new(),
|
||||||
},
|
},
|
||||||
};
|
}));
|
||||||
if let Some(sketch_on_face_source_range) = sketch_on_face_source_range {
|
|
||||||
let range = sketch_on_face_source_range;
|
|
||||||
cap_artifact.face_code_ref = CodeRef {
|
|
||||||
range: *range,
|
|
||||||
path_to_node: path_to_node.clone(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return_arr.push(Artifact::Cap(cap_artifact));
|
|
||||||
let Some(Artifact::Sweep(sweep)) = artifacts.get(&path_sweep_id) else {
|
let Some(Artifact::Sweep(sweep)) = artifacts.get(&path_sweep_id) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user