diff options
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index af21254e4..013345acb 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -506,12 +506,19 @@ pub fn handle_hover( | |||
506 | ) -> Result<Option<Hover>> { | 506 | ) -> Result<Option<Hover>> { |
507 | let position = params.try_conv_with(&world)?; | 507 | let position = params.try_conv_with(&world)?; |
508 | let line_index = world.analysis().file_line_index(position.file_id); | 508 | let line_index = world.analysis().file_line_index(position.file_id); |
509 | let file = world.analysis().file_syntax(position.file_id); | ||
509 | 510 | ||
510 | for (file_id, symbol) in world.analysis().approximately_resolve_symbol(position)? { | 511 | for (file_id, symbol) in world.analysis().approximately_resolve_symbol(position)? { |
511 | let range = symbol.node_range.conv_with(&line_index); | ||
512 | let comment = world.analysis.doc_comment_for(file_id, symbol)?; | 512 | let comment = world.analysis.doc_comment_for(file_id, symbol)?; |
513 | 513 | ||
514 | if comment.is_some() { | 514 | if comment.is_some() { |
515 | let range = match ra_syntax::algo::find_leaf_at_offset(file.syntax(), position.offset) | ||
516 | .left_biased() | ||
517 | { | ||
518 | None => return Ok(None), | ||
519 | Some(it) => it.range(), | ||
520 | }; | ||
521 | let range = range.conv_with(&line_index); | ||
515 | let contents = HoverContents::Scalar(MarkedString::String(comment.unwrap())); | 522 | let contents = HoverContents::Scalar(MarkedString::String(comment.unwrap())); |
516 | 523 | ||
517 | return Ok(Some(Hover { | 524 | return Ok(Some(Hover { |