Repository navigation
Fix auto-import not offering unsaved exports after auto-imports were computed - #64960
Open
Harsh Vardhan Chauhan (1-DARK) wants to merge 1 commit into
Open
Harsh Vardhan Chauhan (1-DARK) wants to merge 1 commit into
Harsh Vardhan Chauhan (1-DARK) wants to merge 1 commit into
Conversation
…a batch markBucketsDirty removed a bucket from the clean set after its first dirty file (when multipleFilesDirty was false) instead of once it was fully dirty. Subsequent changed files in the same batch were skipped, so an export that only existed as unsaved content was never re-indexed. Add a regression test.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused condition fixes match the bucket-state semantics, and the regression test covers the reported failure sequence with no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes #64953 by correcting auto-import cache invalidation so unsaved exports are indexed when multiple file changes arrive in one batch.
Changes:
- Keeps project and node_modules buckets eligible for further invalidation until they are fully dirty.
- Adds a regression test covering the close/reopen sequence that previously left unsaved exports unindexed.
| File | Description |
|---|---|
tsc/internal/ls/autoimport/registry.go |
Corrects three conditions that prematurely stopped processing bucket changes. |
tsc/internal/ls/autoimport/registry_test.go |
Verifies unsaved exports are indexed after auto-imports were previously computed. |
Review effort: Balanced
Author
|
@microsoft-github-policy-service agree |
Ryan Cavanaugh (RyanCavanaugh)
approved these changes
Oct 26, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #64953
markBucketsDirtyremoved a bucket from the "clean" set after its first dirty file (whenmultipleFilesDirtywas false), instead of once thebucket was fully dirty. Any further changed files in the same batch were then skipped.
In the reported sequence, closing
importer.tsand openingexporter.tsland in one batch. The Deleted importer was processed first, so theChanged
exporter.tswas never marked dirty. The bucket kept the stale (empty)exporter.ts, andunsavedFnwas never offered as an auto-import,via completion or
getImportEditsForSymbols.The condition was inverted in three places (the project bucket and both node_modules paths). Each now removes the bucket only when
multipleFilesDirtyis true.Tests
Adds
TestUnsavedExportAfterAutoImportsComputedintsc/internal/ls/autoimport/registry_test.go. It follows the reported sequence: open importer,request auto-imports, close importer, open exporter with unsaved content, reopen importer, request auto-imports. It then asserts that the project
bucket indexed the export.
importer.tsand hasExportCount:0.Other checks:
go test ./internal/project/... ./internal/ls/... ./internal/fourslash/...passes.npx hereby lint: 0 issues.npx hereby check:format: passes.go test ./...: the only failure isastnavTestGetTouchingPropertyName. It also fails without this change.Verification
Ran https://github.com/johnsoncodehk/tsgo-auto-import-unsaved-export-repro against a local build, using this repo's JS API client.
Before the fix:
After the fix: