Skip to content

Commit

Permalink
fix: fix stackoverflow in find_node_impl
Browse files Browse the repository at this point in the history
fix #148
  • Loading branch information
HerringtonDarkholme committed Dec 24, 2022
1 parent 9328cd7 commit 33693d5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/core/src/matcher.rs
Expand Up @@ -90,12 +90,14 @@ where
L: Language,
M: Matcher<L> + ?Sized,
{
if set.contains(node.kind_id().into()) {
if let Some(ret) = m.match_node(node.clone()) {
return Some(ret);
for n in node.dfs() {
if set.contains(n.kind_id().into()) {
if let Some(ret) = m.match_node(n.clone()) {
return Some(ret);
}
}
}
node.children().find_map(|sub| find_node_impl(m, sub, set))
None
}

impl<L: Language> Matcher<L> for str {
Expand Down

0 comments on commit 33693d5

Please sign in to comment.