From 394a3dbcb58dbce3df8d4de1816a41eb41c0e7b3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 25 Jun 2020 10:16:06 +0200 Subject: Fix matchig brace for pipes --- crates/ra_ide/src/matching_brace.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ra_ide/src/matching_brace.rs b/crates/ra_ide/src/matching_brace.rs index 685ba10ad..742d70c9c 100644 --- a/crates/ra_ide/src/matching_brace.rs +++ b/crates/ra_ide/src/matching_brace.rs @@ -32,7 +32,10 @@ pub fn matching_brace(file: &SourceFile, offset: TextSize) -> Option { return None; } let matching_kind = BRACES[brace_idx ^ 1]; - let matching_node = parent.children_with_tokens().find(|node| node.kind() == matching_kind)?; + let matching_node = parent + .children_with_tokens() + .filter_map(|it| it.into_token()) + .find(|node| node.kind() == matching_kind && node != &brace_token)?; Some(matching_node.text_range().start()) } @@ -57,6 +60,7 @@ mod tests { do_check("struct Foo { a: i32, }<|>", "struct Foo <|>{ a: i32, }"); do_check("fn main() { |x: i32|<|> x * 2;}", "fn main() { <|>|x: i32| x * 2;}"); + do_check("fn main() { <|>|x: i32| x * 2;}", "fn main() { |x: i32<|>| x * 2;}"); { mark::check!(pipes_not_braces); -- cgit v1.2.3