align rslib get_subnode impl with anki pythonapi find_deck_in_tree, fix nestdeck due counts issue

This commit is contained in:
cecini 2020-10-27 11:21:02 +08:00
parent 6b0b3fcd6a
commit 2606a8a489
2 changed files with 6 additions and 2 deletions

View File

@ -66,6 +66,7 @@ David Allison <davidallisongithub@gmail.com>
Tsung-Han Yu <johan456789@gmail.com>
Piotr Kubowicz <piotr.kubowicz@gmail.com>
RumovZ <gp5glkw78@relay.firefox.com>
Cecini <github.com/cecini>
********************

View File

@ -175,9 +175,12 @@ fn hide_default_deck(node: &mut DeckTreeNode) {
}
fn get_subnode(top: DeckTreeNode, target: DeckID) -> Option<DeckTreeNode> {
if top.deck_id == target.0 {
return Some(top);
}
for child in top.children {
if child.deck_id == target.0 {
return Some(child);
if let Some(node) = get_subnode(child, target) {
return Some(node);
}
}