mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
make matching brace consistent
This commit is contained in:
parent
c517696fab
commit
1ec1bd8139
2 changed files with 4 additions and 4 deletions
|
@ -316,8 +316,9 @@ impl Analysis {
|
||||||
|
|
||||||
/// Returns position of the mathcing brace (all types of braces are
|
/// Returns position of the mathcing brace (all types of braces are
|
||||||
/// supported).
|
/// supported).
|
||||||
pub fn matching_brace(&self, file: &SourceFile, offset: TextUnit) -> Option<TextUnit> {
|
pub fn matching_brace(&self, position: FilePosition) -> Option<TextUnit> {
|
||||||
ra_ide_api_light::matching_brace(file, offset)
|
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.
|
/// Returns a syntax tree represented as `String`, for debug purposes.
|
||||||
|
|
|
@ -51,7 +51,6 @@ pub fn handle_find_matching_brace(
|
||||||
params: req::FindMatchingBraceParams,
|
params: req::FindMatchingBraceParams,
|
||||||
) -> Result<Vec<Position>> {
|
) -> Result<Vec<Position>> {
|
||||||
let file_id = params.text_document.try_conv_with(&world)?;
|
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 line_index = world.analysis().file_line_index(file_id);
|
||||||
let res = params
|
let res = params
|
||||||
.offsets
|
.offsets
|
||||||
|
@ -60,7 +59,7 @@ pub fn handle_find_matching_brace(
|
||||||
.map(|offset| {
|
.map(|offset| {
|
||||||
world
|
world
|
||||||
.analysis()
|
.analysis()
|
||||||
.matching_brace(&file, offset)
|
.matching_brace(FilePosition { file_id, offset })
|
||||||
.unwrap_or(offset)
|
.unwrap_or(offset)
|
||||||
})
|
})
|
||||||
.map_conv_with(&line_index)
|
.map_conv_with(&line_index)
|
||||||
|
|
Loading…
Reference in a new issue