Select: the font Same commands take their reference from the type on a selected layer

A layer that was selected (for example with select.set) gave no reference to
Select > Same > Font Family, Font Family & Style, Font Family, Style & Size,
Font Size and the text fill and stroke color commands: the layer itself is
not selectable, so the type on it was never reached and the command returned
"select a text object". A selected layer or sublayer now gives the type on it
that can be selected. A hidden, locked or template layer gives none.
This commit is contained in:
dotCooCoo
2026-11-04 12:44:48 +07:00
committed by bflatastic
parent 5c224a0d08
commit f581aa8a56
2 changed files with 42 additions and 5 deletions
+12 -5
View File
@@ -328,8 +328,9 @@ fn same_text(s: &mut Session, cmd: &str, eq: fn(&CharStyle, &CharStyle) -> bool)
/// Call `f` with each type object among the selected objects and inside them, in selection order,
/// keeping only those [`walk_selectable`] visits: none that is hidden, locked, on a hidden, locked
/// or template layer, or outside the isolated group. A type object inside two selected objects is
/// given twice. The walk stops when `f` returns false.
/// or template layer, or outside the isolated group. A selected layer or sublayer gives the type
/// on it that passes the same test. A type object inside two selected objects is given twice. The
/// walk stops when `f` returns false.
fn each_selected_text(s: &Session, mut f: impl FnMut(NodeId) -> bool) {
fn inside(n: &Node, f: &mut impl FnMut(NodeId) -> bool) -> bool {
if !n.visible || n.locked {
@@ -340,12 +341,18 @@ fn each_selected_text(s: &Session, mut f: impl FnMut(NodeId) -> bool) {
}
n.children().into_iter().flatten().all(|c| inside(c, f))
}
fn from(n: &Node, selectable: &impl Fn(NodeId) -> bool, f: &mut impl FnMut(NodeId) -> bool) -> bool {
if n.is_layer() {
return n.children().into_iter().flatten().all(|c| from(c, selectable, f));
}
!selectable(n.id) || inside(n, f)
}
let Some(st) = s.active() else { return };
let locks = st.doc.locked_artboards();
let selectable = |id| is_selectable(&st.doc, st.isolation, &locks, id);
for id in &st.selection.objects {
if is_selectable(&st.doc, st.isolation, &locks, *id)
&& let Some(n) = st.doc.node(*id)
&& !inside(n, &mut f)
if let Some(n) = st.doc.node(*id)
&& !from(n, &selectable, &mut f)
{
return;
}