aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/matching_brace.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/matching_brace.rs')
-rw-r--r--crates/ra_ide_api/src/matching_brace.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/matching_brace.rs b/crates/ra_ide_api/src/matching_brace.rs
index bebd16a69..eaa4b620c 100644
--- a/crates/ra_ide_api/src/matching_brace.rs
+++ b/crates/ra_ide_api/src/matching_brace.rs
@@ -1,13 +1,14 @@
1use ra_syntax::{ 1use ra_syntax::{
2 SourceFile, TextUnit, 2 SourceFile, TextUnit,
3 algo::find_token_at_offset, 3 algo::find_token_at_offset,
4 SyntaxKind::{self, *}, 4 SyntaxKind::{self},
5 ast::AstNode, 5 ast::AstNode,
6 T
6}; 7};
7 8
8pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { 9pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> {
9 const BRACES: &[SyntaxKind] = 10 const BRACES: &[SyntaxKind] =
10 &[L_CURLY, R_CURLY, L_BRACK, R_BRACK, L_PAREN, R_PAREN, L_ANGLE, R_ANGLE]; 11 &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>]];
11 let (brace_node, brace_idx) = find_token_at_offset(file.syntax(), offset) 12 let (brace_node, brace_idx) = find_token_at_offset(file.syntax(), offset)
12 .filter_map(|node| { 13 .filter_map(|node| {
13 let idx = BRACES.iter().position(|&brace| brace == node.kind())?; 14 let idx = BRACES.iter().position(|&brace| brace == node.kind())?;