Skip to content

Commit

Permalink
refactor traverse_up_to_node_which_matters
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Jan 23, 2021
1 parent 8c0b6b4 commit b9dcc88
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,11 @@ fn traverse_up_to_node_which_matters<'a>(
filetype_config: &FiletypeConfig,
current_node: Node<'a>,
) -> Node<'a> {
let mut node = current_node;
while let Some(parent) = if node.is_named() && filetype_config.is_node_visible(node) {
None
} else {
node.parent()
} {
node = parent;
let mut opt_node = Some(current_node);
while let Some(node) = opt_node.filter(|&n| !(n.is_named() && filetype_config.is_node_visible(n))) {
opt_node = node.parent();
}
node
opt_node.unwrap_or(current_node)
}

fn find_parent_of_interest<'a>(
Expand Down

0 comments on commit b9dcc88

Please sign in to comment.