Fix grandchild tag not being reparentable under the same root (#2148)
Introduced in #2146
This commit is contained in:
parent
c2a3e67b0b
commit
abbfdbf420
@ -97,7 +97,7 @@ fn reparented_name(existing_name: &str, new_parent: Option<&str>) -> Option<Stri
|
|||||||
let existing_root = existing_name.split("::").next().unwrap();
|
let existing_root = existing_name.split("::").next().unwrap();
|
||||||
if let Some(new_parent) = new_parent {
|
if let Some(new_parent) = new_parent {
|
||||||
let new_parent_root = new_parent.split("::").next().unwrap();
|
let new_parent_root = new_parent.split("::").next().unwrap();
|
||||||
if new_parent_root == existing_root {
|
if new_parent.starts_with(existing_name) && new_parent_root == existing_root {
|
||||||
// foo onto foo::bar, or foo onto itself -> no-op
|
// foo onto foo::bar, or foo onto itself -> no-op
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
@ -233,6 +233,25 @@ mod test {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// grandchildren can be reparented under the same root
|
||||||
|
col.reparent_tags(
|
||||||
|
&["parent2::child1::grandchild1".to_string()],
|
||||||
|
Some("parent2".to_string()),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
alltags(&col),
|
||||||
|
&[
|
||||||
|
"ab",
|
||||||
|
"ab::a",
|
||||||
|
"another",
|
||||||
|
"parent1",
|
||||||
|
"parent2",
|
||||||
|
"parent2::child1",
|
||||||
|
"parent2::grandchild1",
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user