aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/matching_brace.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-05-15 16:22:39 +0100
committerLukas Wirth <[email protected]>2021-05-15 16:22:39 +0100
commit3da52d2e936bf797d7fe1a9c6c9fad78e19c7d83 (patch)
treeaf57c9ea7bff5622c240085357f2ec8b5524f763 /crates/ide/src/matching_brace.rs
parente5e6c363dc7ef081d6c9a5377563d3632c579ab2 (diff)
simplify
Diffstat (limited to 'crates/ide/src/matching_brace.rs')
-rw-r--r--crates/ide/src/matching_brace.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/crates/ide/src/matching_brace.rs b/crates/ide/src/matching_brace.rs
index 261dcc255..011c8cc55 100644
--- a/crates/ide/src/matching_brace.rs
+++ b/crates/ide/src/matching_brace.rs
@@ -19,14 +19,10 @@ use syntax::{
19pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<TextSize> { 19pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<TextSize> {
20 const BRACES: &[SyntaxKind] = 20 const BRACES: &[SyntaxKind] =
21 &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>], T![|], T![|]]; 21 &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>], T![|], T![|]];
22 let (brace_token, brace_idx) = file 22 let (brace_token, brace_idx) = file.syntax().token_at_offset(offset).find_map(|node| {
23 .syntax() 23 let idx = BRACES.iter().position(|&brace| brace == node.kind())?;
24 .token_at_offset(offset) 24 Some((node, idx))
25 .filter_map(|node| { 25 })?;
26 let idx = BRACES.iter().position(|&brace| brace == node.kind())?;
27 Some((node, idx))
28 })
29 .next()?;
30 let parent = brace_token.parent()?; 26 let parent = brace_token.parent()?;
31 if brace_token.kind() == T![|] && !ast::ParamList::can_cast(parent.kind()) { 27 if brace_token.kind() == T![|] && !ast::ParamList::can_cast(parent.kind()) {
32 cov_mark::hit!(pipes_not_braces); 28 cov_mark::hit!(pipes_not_braces);