diff options
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index af3cd04ea..307082865 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -481,7 +481,6 @@ pub fn handle_references( | |||
481 | params: req::ReferenceParams, | 481 | params: req::ReferenceParams, |
482 | ) -> Result<Option<Vec<Location>>> { | 482 | ) -> Result<Option<Vec<Location>>> { |
483 | let position = params.text_document_position.try_conv_with(&world)?; | 483 | let position = params.text_document_position.try_conv_with(&world)?; |
484 | let line_index = world.analysis().file_line_index(position.file_id)?; | ||
485 | 484 | ||
486 | let refs = match world.analysis().find_all_refs(position)? { | 485 | let refs = match world.analysis().find_all_refs(position)? { |
487 | None => return Ok(None), | 486 | None => return Ok(None), |
@@ -490,13 +489,19 @@ pub fn handle_references( | |||
490 | 489 | ||
491 | let locations = if params.context.include_declaration { | 490 | let locations = if params.context.include_declaration { |
492 | refs.into_iter() | 491 | refs.into_iter() |
493 | .filter_map(|r| to_location(r.file_id, r.range, &world, &line_index).ok()) | 492 | .filter_map(|r| { |
493 | let line_index = world.analysis().file_line_index(r.file_id).ok()?; | ||
494 | to_location(r.file_id, r.range, &world, &line_index).ok() | ||
495 | }) | ||
494 | .collect() | 496 | .collect() |
495 | } else { | 497 | } else { |
496 | // Only iterate over the references if include_declaration was false | 498 | // Only iterate over the references if include_declaration was false |
497 | refs.references() | 499 | refs.references() |
498 | .iter() | 500 | .iter() |
499 | .filter_map(|r| to_location(r.file_id, r.range, &world, &line_index).ok()) | 501 | .filter_map(|r| { |
502 | let line_index = world.analysis().file_line_index(r.file_id).ok()?; | ||
503 | to_location(r.file_id, r.range, &world, &line_index).ok() | ||
504 | }) | ||
500 | .collect() | 505 | .collect() |
501 | }; | 506 | }; |
502 | 507 | ||
@@ -746,6 +751,7 @@ pub fn handle_document_highlight( | |||
746 | 751 | ||
747 | Ok(Some( | 752 | Ok(Some( |
748 | refs.into_iter() | 753 | refs.into_iter() |
754 | .filter(|r| r.file_id == file_id) | ||
749 | .map(|r| DocumentHighlight { range: r.range.conv_with(&line_index), kind: None }) | 755 | .map(|r| DocumentHighlight { range: r.range.conv_with(&line_index), kind: None }) |
750 | .collect(), | 756 | .collect(), |
751 | )) | 757 | )) |