Fix strokes with inside/outside alignment not being selectable when above other layers#4207
Fix strokes with inside/outside alignment not being selectable when above other layers#4207Keavon wants to merge 1 commit into
Conversation
…bove other layers
There was a problem hiding this comment.
Code Review
This pull request updates the click target calculation in extend_targets_from_vector to double the stroke width for inside/outside-aligned strokes on closed paths. The reviewer suggested optimizing this logic by combining the subpath collection, closed-path check, and closure modification into a single pass over the iterator to avoid multiple iterations over the allocated vector.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| let mut subpaths: Vec<Subpath<_>> = vector.stroke_bezier_paths().collect(); | ||
| let all_subpaths_closed = subpaths.iter().all(|subpath| subpath.closed()); | ||
|
|
||
| // Inside/Outside-aligned strokes reach `weight` from the centerline rather than `weight / 2` per side, | ||
| // so they need double the click inflation. Alignment is only honored by the renderer for fully-closed paths. | ||
| let stroke_width = vector.style.stroke().map_or(0., |stroke| { | ||
| if stroke.align.is_not_centered() && all_subpaths_closed { | ||
| stroke.weight * 2. | ||
| } else { | ||
| stroke.weight | ||
| } | ||
| }); | ||
|
|
||
| if filled { | ||
| for subpath in &mut subpaths { | ||
| subpath.set_closed(true); | ||
| } | ||
| } |
There was a problem hiding this comment.
We can optimize this by combining the collection, closed-path check, and closure modification into a single pass over the iterator. This avoids iterating over the allocated Vec multiple times.
let mut all_subpaths_closed = true;
let mut subpaths: Vec<Subpath<__>> = vector
.stroke_bezier_paths()
.map(|mut subpath| {
if !subpath.closed() {
all_subpaths_closed = false;
}
if filled {
subpath.set_closed(true);
}
subpath
})
.collect();
// Inside/Outside-aligned strokes reach weight from the centerline rather than weight / 2 per side,
// so they need double the click inflation. Alignment is only honored by the renderer for fully-closed paths.
let stroke_width = vector.style.stroke().map_or(0., |stroke| {
if stroke.align.is_not_centered() && all_subpaths_closed {
stroke.weight * 2.
} else {
stroke.weight
}
});
Fixes #4206