Problem
When hovering over a comment inside a function body, the hover tooltip shows the function's type info and the highlight range covers the entire function definition. This is because the innermost AST node at the comment's position is the enclosing FunctionDef, which the hover handler then resolves as the function symbol.
Comments are not represented in the AST (they're stored as trivia on tokens), so FindNodeAtPosition falls through to the enclosing node.
Expected behavior
- Hovering over a comment should not trigger the hover of its enclosing context (function, class, etc.)
- Ideally, comments should show their own content in the hover tooltip, with markdown formatting — especially useful for multiline comments
Reproduction
- Open any
.spy file with a comment inside a function
- Hover over the comment text
- Observe: the entire function definition highlights and the tooltip shows the function's type signature
Possible approaches
- Suppress hover for comment positions: Check if the cursor position falls within a trivia/comment span before resolving hover. If so, return null (or the comment content).
- Show comment content: Format the comment text as a hover tooltip (strip
# prefix, render as markdown). This would be useful for multiline doc comments.
Reported during LSP review session.
Problem
When hovering over a comment inside a function body, the hover tooltip shows the function's type info and the highlight range covers the entire function definition. This is because the innermost AST node at the comment's position is the enclosing
FunctionDef, which the hover handler then resolves as the function symbol.Comments are not represented in the AST (they're stored as trivia on tokens), so
FindNodeAtPositionfalls through to the enclosing node.Expected behavior
Reproduction
.spyfile with a comment inside a functionPossible approaches
#prefix, render as markdown). This would be useful for multiline doc comments.Reported during LSP review session.