From 2606a8a489060deb3faeee91759c70b4165fc03e Mon Sep 17 00:00:00 2001 From: cecini Date: Tue, 27 Oct 2020 11:21:02 +0800 Subject: [PATCH] align rslib get_subnode impl with anki pythonapi find_deck_in_tree, fix nestdeck due counts issue --- CONTRIBUTORS | 1 + rslib/src/decks/tree.rs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index c85c3ae31..c0c1c2088 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -66,6 +66,7 @@ David Allison Tsung-Han Yu Piotr Kubowicz RumovZ +Cecini ******************** diff --git a/rslib/src/decks/tree.rs b/rslib/src/decks/tree.rs index d42015180..b60d7b794 100644 --- a/rslib/src/decks/tree.rs +++ b/rslib/src/decks/tree.rs @@ -175,9 +175,12 @@ fn hide_default_deck(node: &mut DeckTreeNode) { } fn get_subnode(top: DeckTreeNode, target: DeckID) -> Option { + 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); } }