Skip to content

Commit 5a5ad69

Browse files
committed
css: fix language model cache evicting at capacity instead of overflow
The `getLanguageModelCache` eviction check used `===` to compare the current entry count against `maxEntries`, which triggered eviction as soon as the cache reached its maximum size. As a result the cache only held `maxEntries - 1` entries at steady state instead of the intended `maxEntries`. Changing the condition to `>` ensures eviction only occurs when the count exceeds `maxEntries`, allowing the cache to retain the full number of intended entries.
1 parent f4e6a58 commit 5a5ad69

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

extensions/css-language-features/server/src/languageModelCache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTime
4545
nModels++;
4646
}
4747

48-
if (nModels === maxEntries) {
48+
if (nModels > maxEntries) {
4949
let oldestTime = Number.MAX_VALUE;
5050
let oldestUri = null;
5151
for (const uri in languageModels) {

0 commit comments

Comments
 (0)