From ed7ae78c6fd9e508f6e959c6a164cf8481f6b377 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 17 Aug 2018 19:54:08 +0300 Subject: ServerWorld --- crates/libeditor/src/code_actions.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'crates/libeditor/src') 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 Option { - find_leaf_at_offset(syntax, offset) - .find(|leaf| !leaf.kind().is_trivia()) -} - pub fn find_node<'a, N: AstNode<&'a SyntaxRoot>>(syntax: SyntaxNodeRef<'a>, offset: TextUnit) -> Option { - let leaf = find_non_trivia_leaf(syntax, offset)?; + let leaves = find_leaf_at_offset(syntax, offset); + let leaf = leaves.clone() + .find(|leaf| !leaf.kind().is_trivia()) + .or_else(|| leaves.right_biased())?; ancestors(leaf) .filter_map(N::cast) .next() -- cgit v1.2.3