From 1ec1bd8139251092e567d0b6034f96e3fdf33afb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 20 Jan 2019 20:59:46 +0300 Subject: make matching brace consistent --- crates/ra_ide_api/src/lib.rs | 5 +++-- crates/ra_lsp_server/src/main_loop/handlers.rs | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index ca6b25516..9ee5467ed 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs @@ -316,8 +316,9 @@ impl Analysis { /// Returns position of the mathcing brace (all types of braces are /// supported). - pub fn matching_brace(&self, file: &SourceFile, offset: TextUnit) -> Option { - ra_ide_api_light::matching_brace(file, offset) + pub fn matching_brace(&self, position: FilePosition) -> Option { + let file = self.db.source_file(position.file_id); + ra_ide_api_light::matching_brace(&file, position.offset) } /// Returns a syntax tree represented as `String`, for debug purposes. diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 8f9db68a2..b70d67b4d 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -51,7 +51,6 @@ pub fn handle_find_matching_brace( params: req::FindMatchingBraceParams, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; - let file = world.analysis().file_syntax(file_id); let line_index = world.analysis().file_line_index(file_id); let res = params .offsets @@ -60,7 +59,7 @@ pub fn handle_find_matching_brace( .map(|offset| { world .analysis() - .matching_brace(&file, offset) + .matching_brace(FilePosition { file_id, offset }) .unwrap_or(offset) }) .map_conv_with(&line_index) -- cgit v1.2.3