diff options
author | DJMcNab <[email protected]> | 2018-12-06 22:56:39 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-12-08 16:28:10 +0000 |
commit | 3d3026dc6072bc52cd01f6dca4bbdf1df450da02 (patch) | |
tree | 86d0fe515961d0a38bd026f92933a02dff4b566e | |
parent | 66f656134f349f943905cfe44f5005263dc635f9 (diff) |
Fix the range of a hover request to be more in line with prior art
-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 { |