aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src/lib.rs')
-rw-r--r--crates/ra_editor/src/lib.rs7
1 files changed, 1 insertions, 6 deletions
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs
index ff4e8303d..c6b116159 100644
--- a/crates/ra_editor/src/lib.rs
+++ b/crates/ra_editor/src/lib.rs
@@ -148,12 +148,7 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>(
148 syntax: SyntaxNodeRef<'a>, 148 syntax: SyntaxNodeRef<'a>,
149 offset: TextUnit, 149 offset: TextUnit,
150) -> Option<N> { 150) -> Option<N> {
151 let leaves = find_leaf_at_offset(syntax, offset); 151 find_leaf_at_offset(syntax, offset).find_map(|leaf| leaf.ancestors().find_map(N::cast))
152 let leaf = leaves
153 .clone()
154 .find(|leaf| !leaf.kind().is_trivia())
155 .or_else(|| leaves.right_biased())?;
156 leaf.ancestors().filter_map(N::cast).next()
157} 152}
158 153
159#[cfg(test)] 154#[cfg(test)]