You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Registry.specifierCache was only cleared when autoImportSpecifierExcludeRegexes changed, so a change to importModuleSpecifierPreference or importModuleSpecifierEnding kept returning specifiers computed with the old preferences for files that were already open.
This compares all preferences returned by ModuleSpecifierPreferences() (the ones passed to GetModuleSpecifier) through a new modulespecifiers.UserPreferences.Equal, and clears the cache only when they differ.
Added TestUserPreferencesEqual, and TestAutoImportModuleSpecifierAfterUserPreferenceChange, which changes autoImportSpecifierExcludeRegexes, importModuleSpecifierEnding and importModuleSpecifierPreference one at a time on an open file and checks the auto-import specifier after each change.
This clears the cache on every user preference change
This is a strong claim that isn't well-supported by the code. It's allowed for the editor to re-send config even in the absence of a change, and it's easy to set up your editor to allow toggling preferences a lot for whatever reason (e.g. inlay hints). Without stronger justification than "it's rare so it's OK" I'd really prefer this just be done correctly (check the preferences values that matter).
lsh4711
changed the title
Clear auto-import specifier cache when user preferences change
Clear auto-import specifier cache when module specifier preferences change
Oct 15, 2026
Thanks, that's fair. I changed it to clear the cache only when the preferences returned by ModuleSpecifierPreferences() change, which are the ones passed to GetModuleSpecifier. I added an Equal method next to modulespecifiers.UserPreferences (following bucketBuildPreferences.Equal), so a field added to that struct is next to its comparison, and a unit test for it.
This branch has not been deployed
No deployments
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
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 #64820
Registry.specifierCachewas only cleared whenautoImportSpecifierExcludeRegexeschanged, so a change toimportModuleSpecifierPreferenceorimportModuleSpecifierEndingkept returning specifiers computed with the old preferences for files that were already open.This compares all preferences returned by
ModuleSpecifierPreferences()(the ones passed toGetModuleSpecifier) through a newmodulespecifiers.UserPreferences.Equal, and clears the cache only when they differ.Added
TestUserPreferencesEqual, andTestAutoImportModuleSpecifierAfterUserPreferenceChange, which changesautoImportSpecifierExcludeRegexes,importModuleSpecifierEndingandimportModuleSpecifierPreferenceone at a time on an open file and checks the auto-import specifier after each change.