mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Fix matchig brace for pipes
This commit is contained in:
parent
193ea7cf9a
commit
394a3dbcb5
1 changed files with 5 additions and 1 deletions
|
@ -32,7 +32,10 @@ pub fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<TextSize> {
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue