Skip to content

Properly track first Quick Info declaration + fix issue in fourslash#2641

Merged
ahejlsberg merged 7 commits intomainfrom
fix-2599-2
Feb 2, 2026
Merged

Properly track first Quick Info declaration + fix issue in fourslash#2641
ahejlsberg merged 7 commits intomainfrom
fix-2599-2

Conversation

@ahejlsberg
Copy link
Member

This is a follow-up PR to #2627 that fixes the issue reported here.

The PR also fixes an issue in fourslash that caused baseline verification of Quick Info to not work in multi-file tests.

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 fixes two issues related to Quick Info functionality: properly tracking the first declaration when displaying Quick Info, and correcting baseline verification for multi-file fourslash tests.

Changes:

  • Refactored declaration tracking in Quick Info to use a guard pattern that captures the first declaration encountered
  • Fixed fourslash test infrastructure to use marker.fileName instead of f.activeFilename for hover requests in multi-file tests
  • Added a new test case for merged alias Quick Info scenarios

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

File Description
internal/ls/hover.go Refactored writeSymbol to not return a declaration directly; introduced setDeclaration helper that only sets firstDeclaration if it's nil, ensuring the first declaration is properly tracked across recursive calls
internal/fourslash/fourslash.go Fixed bug where hover requests used active filename instead of marker's actual filename, causing incorrect behavior in multi-file tests
internal/fourslash/tests/quickInfoMergedAlias_test.go Added test case covering merged alias scenarios across multiple files
testdata/baselines/reference/fourslash/quickInfo/*.baseline Updated baselines showing fixes - markers that previously had null Quick Info now display proper content

flags = symbol.Flags & (ast.SymbolFlagsValue | ast.SymbolFlagsSignature | ast.SymbolFlagsType | ast.SymbolFlagsNamespace)
}
if flags == 0 {
if aliasLevel != 0 || b.Len() != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I get checking the alias level, but why do we need to check if b.Len() != 0 here?

Copy link
Member Author

@ahejlsberg ahejlsberg Feb 2, 2026

Choose a reason for hiding this comment

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

The check is here such that we reach the subsequent logic only when aliasLevel is zero and nothing has been output yet. In that case we want to do a final sanity check where we output any meaning of the symbol, even if getMeaningFromLocation doesn't indicate it. There are cases where getMeaningFromLocation returns "wrong" results because of errors in the source file, for example during completion (and completion actually invokes Quick Info).

@jakebailey
Copy link
Member

You fixed four generated tests, so you should be able to do npm run updatefailing

@ahejlsberg ahejlsberg enabled auto-merge February 2, 2026 18:08
@ahejlsberg ahejlsberg added this pull request to the merge queue Feb 2, 2026
Merged via the queue into main with commit 297d6ea Feb 2, 2026
21 checks passed
@ahejlsberg ahejlsberg deleted the fix-2599-2 branch February 2, 2026 18:37
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.

4 participants