Skip to content

Commit 6e12a02

Browse files
Copilotjakebailey
andcommitted
Fix inverted condition for module references in document highlights
The condition checking whether to return early for module references was inverted. The TypeScript implementation returns early when the symbol is NOT transient, but the Go code was returning early only when it IS transient. This caused module symbols (whose declarations are SourceFiles with no parent) to be passed to getReferencedSymbolsForSymbol, which then called skipPastExportOrImportSpecifierOrUnion. That function would panic when encountering a declaration without a parent for a non-transient symbol. The fix aligns the Go implementation with the TypeScript source by checking for `== 0` instead of `!= 0` on the transient flag. Co-authored-by: jakebailey <[email protected]>
1 parent 51d5fe5 commit 6e12a02

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

internal/ls/findallreferences.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit
673673
}
674674

675675
moduleReferences := l.getReferencedSymbolsForModuleIfDeclaredBySourceFile(ctx, symbol, program, sourceFiles, checker, options, sourceFilesSet) // !!! cancellationToken
676-
if moduleReferences != nil && symbol.Flags&ast.SymbolFlagsTransient != 0 {
676+
if moduleReferences != nil && symbol.Flags&ast.SymbolFlagsTransient == 0 {
677677
return moduleReferences
678678
}
679679

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// === documentHighlights ===
2+
// === /b.ts ===
3+
// import { foo } from "/*HIGHLIGHTS*/my-module";

0 commit comments

Comments
 (0)