From 3d3026dc6072bc52cd01f6dca4bbdf1df450da02 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Thu, 6 Dec 2018 22:56:39 +0000 Subject: Fix the range of a hover request to be more in line with prior art --- crates/ra_lsp_server/src/main_loop/handlers.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') 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( ) -> Result> { let position = params.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(position.file_id); + let file = world.analysis().file_syntax(position.file_id); for (file_id, symbol) in world.analysis().approximately_resolve_symbol(position)? { - let range = symbol.node_range.conv_with(&line_index); let comment = world.analysis.doc_comment_for(file_id, symbol)?; if comment.is_some() { + let range = match ra_syntax::algo::find_leaf_at_offset(file.syntax(), position.offset) + .left_biased() + { + None => return Ok(None), + Some(it) => it.range(), + }; + let range = range.conv_with(&line_index); let contents = HoverContents::Scalar(MarkedString::String(comment.unwrap())); return Ok(Some(Hover { -- cgit v1.2.3