diff options
author | Aleksey Kladov <[email protected]> | 2018-08-17 17:54:08 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-17 17:54:08 +0100 |
commit | ed7ae78c6fd9e508f6e959c6a164cf8481f6b377 (patch) | |
tree | 556e8d4daffefa64dcdc5db8e75299514a0e85e4 /crates/libeditor/src/code_actions.rs | |
parent | 41570f60bf268c97223a864b8aa11a339929f55a (diff) |
ServerWorld
Diffstat (limited to 'crates/libeditor/src/code_actions.rs')
-rw-r--r-- | crates/libeditor/src/code_actions.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/libeditor/src/code_actions.rs b/crates/libeditor/src/code_actions.rs index 6df64be12..4b2515835 100644 --- a/crates/libeditor/src/code_actions.rs +++ b/crates/libeditor/src/code_actions.rs | |||
@@ -71,13 +71,11 @@ fn non_trivia_sibling(node: SyntaxNodeRef, direction: Direction) -> Option<Synta | |||
71 | .find(|node| !node.kind().is_trivia()) | 71 | .find(|node| !node.kind().is_trivia()) |
72 | } | 72 | } |
73 | 73 | ||
74 | fn find_non_trivia_leaf(syntax: SyntaxNodeRef, offset: TextUnit) -> Option<SyntaxNodeRef> { | ||
75 | find_leaf_at_offset(syntax, offset) | ||
76 | .find(|leaf| !leaf.kind().is_trivia()) | ||
77 | } | ||
78 | |||
79 | pub fn find_node<'a, N: AstNode<&'a SyntaxRoot>>(syntax: SyntaxNodeRef<'a>, offset: TextUnit) -> Option<N> { | 74 | pub fn find_node<'a, N: AstNode<&'a SyntaxRoot>>(syntax: SyntaxNodeRef<'a>, offset: TextUnit) -> Option<N> { |
80 | let leaf = find_non_trivia_leaf(syntax, offset)?; | 75 | let leaves = find_leaf_at_offset(syntax, offset); |
76 | let leaf = leaves.clone() | ||
77 | .find(|leaf| !leaf.kind().is_trivia()) | ||
78 | .or_else(|| leaves.right_biased())?; | ||
81 | ancestors(leaf) | 79 | ancestors(leaf) |
82 | .filter_map(N::cast) | 80 | .filter_map(N::cast) |
83 | .next() | 81 | .next() |