]> git.lizzy.rs Git - rust.git/commitdiff
Don't highlight parent nodes of comments on hover
authorLukas Wirth <lukastw97@gmail.com>
Fri, 11 Dec 2020 14:46:47 +0000 (15:46 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Fri, 11 Dec 2020 15:00:52 +0000 (16:00 +0100)
crates/ide/src/hover.rs

index cf04c3de08a053f4fada16e4ebf4c55a7b201a66..ab017d2ada4c6c808b45e6a071f6cc9809dd958b 100644 (file)
@@ -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
+}
+"#,
+        );
+    }
 }