aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs13
1 files changed, 9 insertions, 4 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..a07aaa9b5 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -481,8 +481,7 @@ 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)?; 484
485
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),
488 Some(refs) => refs, 487 Some(refs) => refs,
@@ -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