6824: Don't highlight parent nodes of comments on hover r=kjeremy a=Veykril

Fixes #6815

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2020-12-11 15:02:57 +00:00 committed by GitHub
commit df1f3907af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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
}
"#,
);
}
}