From 37c5b82938040c89a2b7a3756e8bd9b3ae3badd2 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 11 Dec 2020 15:46:47 +0100 Subject: Don't highlight parent nodes of comments on hover --- crates/ide/src/hover.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'crates') diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index cf04c3de0..ab017d2ad 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -139,6 +139,11 @@ pub(crate) fn hover( } } + if token.kind() == syntax::SyntaxKind::COMMENT { + // don't highlight the entire parent node on comment hover + return None; + } + let node = token.ancestors().find(|n| { ast::Expr::can_cast(n.kind()) || ast::Pat::can_cast(n.kind()) @@ -3419,4 +3424,15 @@ mod Foo<|> { "#]], ); } + + #[test] + fn hover_comments_dont_highlight_parent() { + check_hover_no_result( + r#" +fn no_hover() { + // no<|>hover +} +"#, + ); + } } -- cgit v1.2.3