Skip to content

Commit 31026f3

Browse files
committed
fix(bridge): gate getSourceFileByPath on program membership (issue #7)
Stock Program.getSourceFileByPath returns undefined for non-members; Project.containsScriptInfo relies on that for 'does this project contain the file'. The thin program's ungated byPath materialized an SF for ANY path under tsserver, so containsFile over-reported and the session's per-project references worker routed findReferences into non-member projects — whose gated getSourceFile then threw 'Could not find source file'. Surfaced whenever files from two tsconfig projects were open and a references search crossed into the other project's files (e.g. volar component-meta + tsc umbrella in one session). Mirror the getSourceFile gate (lib files stay permissive). With both layers fixed, the #7 repro scenario returns byte-identical reference sets to stock (102/102, 103/103); sim-nav 37,409 units new=0; volar suite 205/205.
1 parent 3153431 commit 31026f3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎patches/typescript/overlay/src/compiler/tsgoChecker.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5043,6 +5043,18 @@ export function createTsgoProgram(
50435043
// toLineColumnOffset (go-to-definition span conversion) sees real line maps.
50445044
getSourceFileByPath: (path: any) => {
50455045
const pathStr = String(path);
5046+
// Membership gate (issue #7): stock Program.getSourceFileByPath
5047+
// returns undefined for non-members — Project.containsScriptInfo
5048+
// relies on that to answer "does this project contain the file".
5049+
// Ungated, tsserver materialized an SF for ANY path here, so
5050+
// containsFile over-reported and the session's per-project
5051+
// references worker routed findReferences into non-member
5052+
// projects whose (gated) getSourceFile then threw "Could not find
5053+
// source file". Lib files keep the permissive path, mirroring
5054+
// getSourceFile above.
5055+
if (!isHostLibFile(toHostFileName(pathStr)) && !programContainsFile(pathStr)) {
5056+
return undefined;
5057+
}
50465058
// Pure-disk lint: the builder's affected-file drain calls this once
50475059
// per changed file (and per graph node on incremental runs). The
50485060
// fileHasHostSourceContent probe below would CREATE a host snapshot

0 commit comments

Comments
 (0)