Fix off by one subpath and unrelated crash (#1754)

* Fix off by one in subpath code

* Fix crash with selected handles and anchor

* Sort the correct way I have no idea why the origional code was so overly verbose but it has caused significant confusion and wasted effort
This commit is contained in:
0HyperCube 2024-05-20 22:44:24 +01:00 committed by GitHub
parent e39539fa08
commit af6dae29fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -982,10 +982,10 @@ impl ShapeState {
continue;
}
selected_points.sort_by(|&a, &b| match a > b {
true => std::cmp::Ordering::Greater,
false => std::cmp::Ordering::Less,
});
selected_points.sort();
// Required to remove duplicates when the handles and anchors are selected
selected_points.dedup();
let mut last_manipulator_index = 0;
let mut to_extend_with_last_group: Option<Vec<ManipulatorGroup<ManipulatorGroupId>>> = None;

View File

@ -324,9 +324,9 @@ impl<'a> Iterator for StrokePathIter<'a> {
.take_while(|&(_, start, end)| {
let continuous = old_end.is_none() || old_end.is_some_and(|old_end| old_end == start);
old_end = Some(end);
count += 1;
continuous
});
})
.inspect(|_| count += 1);
let subpath = self.vector_data.subpath_from_segments(segments_iter);
self.segment_index += count;