Skip to content

Commit 579bedd

Browse files
4adexKeavon
authored andcommitted
Fix editor crash when anchor sliding, followup to #2682 (#2726)
Fix editor crash due to unwrap
1 parent e238753 commit 579bedd

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

editor/src/messages/tool/tool_messages/path_tool.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,14 +2261,17 @@ fn update_dynamic_hints(state: PathToolFsmState, responses: &mut VecDeque<Messag
22612261
let at_least_one_anchor_selected = shape_editor.selected_points().any(|point| matches!(point, ManipulatorPointId::Anchor(_)));
22622262
let at_least_one_point_selected = shape_editor.selected_points().count() >= 1;
22632263

2264-
let single_colinear_anchor_selected = if single_anchor_selected {
2265-
let anchor = shape_editor.selected_points().next().unwrap();
2266-
let layer = document.network_interface.selected_nodes().selected_layers(document.metadata()).next().unwrap();
2267-
let vector_data = document.network_interface.compute_modified_vector(layer).unwrap();
2268-
vector_data.colinear(*anchor)
2269-
} else {
2270-
false
2271-
};
2264+
let mut single_colinear_anchor_selected = false;
2265+
if single_anchor_selected {
2266+
if let (Some(anchor), Some(layer)) = (
2267+
shape_editor.selected_points().next(),
2268+
document.network_interface.selected_nodes().selected_layers(document.metadata()).next(),
2269+
) {
2270+
if let Some(vector_data) = document.network_interface.compute_modified_vector(layer) {
2271+
single_colinear_anchor_selected = vector_data.colinear(*anchor)
2272+
}
2273+
}
2274+
}
22722275

22732276
let mut drag_selected_hints = vec![HintInfo::mouse(MouseMotion::LmbDrag, "Drag Selected")];
22742277
let mut delete_selected_hints = vec![HintInfo::keys([Key::Delete], "Delete Selected")];

0 commit comments

Comments
 (0)