aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-25 09:16:50 +0100
committerGitHub <[email protected]>2020-06-25 09:16:50 +0100
commite2465ee2e949d81f98270c57afa17666dac6afa4 (patch)
treed20fd10c7a0167bbadcb413598b4384a8d042c3f /crates/ra_ide
parent193ea7cf9af8c501035445b42847b6e80b33751a (diff)
parent394a3dbcb58dbce3df8d4de1816a41eb41c0e7b3 (diff)
Merge #5053
5053: Fix matchig brace for pipes r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide')
-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);