Skip to content

Fix issues in Quick Info for symbol-less nodes#3079

Merged
ahejlsberg merged 2 commits intomainfrom
fix-no-symbol-hover
Mar 12, 2026
Merged

Fix issues in Quick Info for symbol-less nodes#3079
ahejlsberg merged 2 commits intomainfrom
fix-no-symbol-hover

Conversation

@ahejlsberg
Copy link
Member

This fixes a couple of issues in #3022:

  • The code here was missing a !.
  • We never reach the code here because the node has a symbol.

I've simplified it some more to avoid passing down a position and to catch all symbol-less declaration nodes.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines Quick Info (hover) behavior for symbol-less nodes in the language service, aiming to fix regressions from #3022 and simplify the implementation by removing position plumbing.

Changes:

  • Updates hover handling to avoid returning quick info for the source file and to attempt suppressing hover in the a/**/.b comment edge case.
  • Simplifies quick info generation APIs by removing the position parameter and narrowing shouldGetType logic to better handle symbol-less declaration names.
  • Adjusts completion-item detail generation to use the updated quick info API.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
internal/ls/hover.go Updates hover early-return logic and simplifies quick info/type fallback logic for symbol-less nodes.
internal/ls/completions.go Updates completion details to call the revised quick info helper without position.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +30 to +31
if node.Kind == ast.KindSourceFile || node.Kind == ast.KindPropertyAccessExpression && isInComment(file, position, node) == nil {
// Avoid giving quickInfo for the sourceFile as a whole or inside the comment of a/**/.b
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new early-return guard in ProvideHover appears to have the comment check inverted and to be calling isInComment with a non-token node. isInComment/getRangeOfEnclosingComment expects a tokenAtPosition (typically from astnav.GetTokenAtPosition), and it returns non-nil when the position is inside a comment. As written, this returns no hover when isInComment(...) == nil (i.e. not in a comment) and may also fail to detect being inside a/**/.b because passing a PropertyAccessExpression (not a token) makes getRangeOfEnclosingComment return nil early. Consider computing tokenAtPosition with astnav.GetTokenAtPosition and returning early when isInComment(...) != nil; also include QualifiedName if you still want to cover A/**/.B in type positions (previous logic handled both).

Suggested change
if node.Kind == ast.KindSourceFile || node.Kind == ast.KindPropertyAccessExpression && isInComment(file, position, node) == nil {
// Avoid giving quickInfo for the sourceFile as a whole or inside the comment of a/**/.b
tokenAtPosition := astnav.GetTokenAtPosition(file, position)
if node.Kind == ast.KindSourceFile || ((node.Kind == ast.KindPropertyAccessExpression || node.Kind == ast.KindQualifiedName) && isInComment(file, position, tokenAtPosition) != nil) {
// Avoid giving quickInfo for the sourceFile as a whole or inside the comment of a/**/.b or A/**/.B

Copilot uses AI. Check for mistakes.
Comment on lines 29 to 32
node := astnav.GetTouchingPropertyName(file, position)
if node.Kind == ast.KindSourceFile {
// Avoid giving quickInfo for the sourceFile as a whole.
if node.Kind == ast.KindSourceFile || node.Kind == ast.KindPropertyAccessExpression && isInComment(file, position, node) == nil {
// Avoid giving quickInfo for the sourceFile as a whole or inside the comment of a/**/.b
return lsproto.HoverOrNull{}, nil
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is fixing a subtle hover/quick-info edge case (cursor inside the /**/ in a/**/.b). There are existing fourslash quick info tests (e.g. hoverOverComment), but I couldn’t find a regression test covering this specific in-between-tokens comment case. Adding a minimal fourslash test that places a marker inside the /**/ and asserts VerifyNotQuickInfoExists (and optionally a QualifiedName variant) would help prevent regressions.

Copilot generated this review using guidance from repository custom instructions.
@ahejlsberg ahejlsberg enabled auto-merge March 12, 2026 19:37
@ahejlsberg ahejlsberg added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit a477d83 Mar 12, 2026
21 checks passed
@ahejlsberg ahejlsberg deleted the fix-no-symbol-hover branch March 12, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants