Skip to content

Avoid rebuilding later LSP project references - #64936

Open
Cheng (chengchuu) wants to merge 1 commit into
microsoft:mainfrom
chengchuu:fix/lsp-referenced-project-rebuild
Open

Cheng (chengchuu) wants to merge 1 commit into
microsoft:mainfrom
chengchuu:fix/lsp-referenced-project-rebuild

Conversation

@chengchuu

@chengchuu Cheng (chengchuu) commented Oct 23, 2026 •

Copy link
Copy Markdown

Summary

Fixes #64862

Avoid repeatedly building later references when a clean, loaded project already contains the opened file. Earlier candidates still run in parallel, preserving reference order and breadth-first selection.

Remove later candidates after traversal, with a fast path in OrderedMap to keep pruning linear. Initial searches can still build unrelated projects; source or configuration changes invalidate the shortcut.

Reproduction

The standalone reproduction opens and closes three files belonging to tsconfig.app.json. Before the fix, the language server built and deleted the unrelated tsconfig.node.json project three times; afterward, it did so only once during initial discovery. All three textDocument/documentSymbol requests succeeded.

Validation

All checks below passed on macOS ARM64, run from the repository root.

go -C tsc test -mod=readonly \
  ./internal/core ./internal/project/... ./internal/lsp/... \
  ./internal/ls/... ./internal/api/... ./cmd/tsc
go -C tsc test -mod=readonly -race \
  ./internal/collections ./internal/core ./internal/project/... ./internal/lsp/...
go -C tsc test -mod=readonly -race ./internal/project \
  -run '^TestProjectCollectionBuilder' -count=10
npx hereby test
npx hereby lint
npx hereby check:format

Copilot AI balanced review requested due to automatic review settings October 23, 2026 15:19
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 23, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Oct 23, 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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@chengchuu

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

🟢 Approval recommended

No unresolved blocking issues were identified, and the reviewed changes include regression coverage for the affected behavior.

No open issues 🎉

Review effort: Lite

@jakebailey Jake Bailey (jakebailey) added the Domain: Performance Performance related label Oct 27, 2026

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

Domain: Performance Performance related For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

TS7 LSP: every didOpen rebuilds and deletes a non-matching referenced project

3 participants