Skip to content

Fix references after unrelated project edits (#64497) - #64550

Open
Shulamit sharabani (SHULMIT) wants to merge 1 commit into
microsoft:mainfrom
SHULMIT:fix-64497-stale-references
Open

Shulamit sharabani (SHULMIT) wants to merge 1 commit into
microsoft:mainfrom
SHULMIT:fix-64497-stale-references

Conversation

@SHULMIT

Copy link
Copy Markdown

Opening a file in an unrelated configured project can unload the configured project containing a source definition. A references request from an inferred project then searches only the loaded projects, so a request on from loses references that a fresh server returns.

Load the source definition's project before expanding a search from an inferred project, excluding declaration files to preserve declaration-map behavior.

Add an LSP regression covering the fresh-session result, an unrelated unsaved edit, and restoring and closing that file.

Fixes #64497.

Validation:

  • The regression fails on unmodified main and passes with this fix.
  • Full LSP, language service, project, and fourslash suites pass without baseline changes.
  • Full Go suite passes with go -C tsc test ./... -skip='/fanotify-no-rename$'.
  • Generation, native/API/extension builds, lint, formatting, module tidy checks, and workspace sync pass.
  • JavaScript API tests (907), extension tests (12), tooling tests (17), and Go/API benchmark smoke checks pass.

The unfiltered watcher tests encounter name_to_handle_at: operation not supported for the fanotify-no-rename backend on this filesystem. Only that unsupported backend variant was excluded from the full Go run; the supported watcher variants pass.

AI assistance: OpenAI Codex authored the fix and regression test and ran the validation.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 00:43
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Sep 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new project load repeats across expansion passes, causing redundant full snapshot rebuilds.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes stale cross-project references after unrelated edits unload a configured project.

Changes:

  • Loads the source definition’s configured project before reference expansion.
  • Adds an LSP regression test for edit, restore, and close scenarios.
File Description
tsc/​internal/​ls/​crossproject.go Loads missing definition projects during cross-project searches.
tsc/​internal/​lsp/​server_references_updates_test.go Covers reference stability across unrelated edits.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +247 to +248
if defaultLs.GetProgram().Options().ConfigFilePath == "" && !tspath.IsDeclarationFileName(defaultDefinition.TextDocumentURI().FileName()) {
if _, errProjects := orchestrator.GetProjectsForFile(ctx, defaultDefinition.TextDocumentURI()); errProjects != nil {

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Find all references on from of a default import drops results after an unsaved edit in another file

2 participants