aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/matching_brace.rs6
1 files changed, 5 insertions, 1 deletions
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<TextSize> {
32 return None; 32 return None;
33 } 33 }
34 let matching_kind = BRACES[brace_idx ^ 1]; 34 let matching_kind = BRACES[brace_idx ^ 1];
35 let matching_node = parent.children_with_tokens().find(|node| node.kind() == matching_kind)?; 35 let matching_node = parent
36 .children_with_tokens()
37 .filter_map(|it| it.into_token())
38 .find(|node| node.kind() == matching_kind && node != &brace_token)?;
36 Some(matching_node.text_range().start()) 39 Some(matching_node.text_range().start())
37} 40}
38 41
@@ -57,6 +60,7 @@ mod tests {
57 60
58 do_check("struct Foo { a: i32, }<|>", "struct Foo <|>{ a: i32, }"); 61 do_check("struct Foo { a: i32, }<|>", "struct Foo <|>{ a: i32, }");
59 do_check("fn main() { |x: i32|<|> x * 2;}", "fn main() { <|>|x: i32| x * 2;}"); 62 do_check("fn main() { |x: i32|<|> x * 2;}", "fn main() { <|>|x: i32| x * 2;}");
63 do_check("fn main() { <|>|x: i32| x * 2;}", "fn main() { |x: i32<|>| x * 2;}");
60 64
61 { 65 {
62 mark::check!(pipes_not_braces); 66 mark::check!(pipes_not_braces);