mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Merge #5053
5053: Fix matchig brace for pipes r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
e2465ee2e9
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;
|
return None;
|
||||||
}
|
}
|
||||||
let matching_kind = BRACES[brace_idx ^ 1];
|
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())
|
Some(matching_node.text_range().start())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +60,7 @@ mod tests {
|
||||||
|
|
||||||
do_check("struct Foo { a: i32, }<|>", "struct Foo <|>{ a: i32, }");
|
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;}");
|
||||||
|
do_check("fn main() { <|>|x: i32| x * 2;}", "fn main() { |x: i32<|>| x * 2;}");
|
||||||
|
|
||||||
{
|
{
|
||||||
mark::check!(pipes_not_braces);
|
mark::check!(pipes_not_braces);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue