From a7ad1bf68652fe74aa0ffc242f9104e33701fbca Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Thu, 26 Oct 2023 18:39:35 +0200 Subject: [PATCH] fix #196640 (#196738) --- .../extensions/browser/fileBasedRecommendations.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/extensions/browser/fileBasedRecommendations.ts b/src/vs/workbench/contrib/extensions/browser/fileBasedRecommendations.ts index c77b79f07cc..47de97ba803 100644 --- a/src/vs/workbench/contrib/extensions/browser/fileBasedRecommendations.ts +++ b/src/vs/workbench/contrib/extensions/browser/fileBasedRecommendations.ts @@ -149,6 +149,7 @@ export class FileBasedRecommendations extends ExtensionRecommendations { const matchedRecommendations: IStringDictionary = {}; const unmatchedRecommendations: IStringDictionary = {}; let listenOnLanguageChange = false; + const languageId = model.getLanguageId(); for (const [extensionId, conditions] of extensionRecommendationEntries) { const conditionsByPattern: IFileOpenCondition[] = []; @@ -165,7 +166,7 @@ export class FileBasedRecommendations extends ExtensionRecommendations { } if (isLanguageCondition) { - if ((condition).languages.includes(model.getLanguageId())) { + if ((condition).languages.includes(languageId)) { languageMatched = true; } } @@ -178,12 +179,13 @@ export class FileBasedRecommendations extends ExtensionRecommendations { processedPathGlobs.set(pathGlob, pathGlobMatched); } - if (!languageMatched && !pathGlobMatched) { - // If the language is not matched and the path glob is not matched, then we don't need to check the other conditions + let matched = languageMatched || pathGlobMatched; + + // If the resource has pattern (extension) and not matched, then we don't need to check the other conditions + if (pattern && !matched) { continue; } - let matched = true; if (matched && condition.whenInstalled) { if (!condition.whenInstalled.every(id => installed.some(local => areSameExtensions({ id }, local.identifier)))) { matched = false; @@ -226,7 +228,9 @@ export class FileBasedRecommendations extends ExtensionRecommendations { } } - this.recommendationsByPattern.set(pattern, recommendationsByPattern); + if (pattern) { + this.recommendationsByPattern.set(pattern, recommendationsByPattern); + } if (Object.keys(unmatchedRecommendations).length) { if (listenOnLanguageChange) { const disposables = new DisposableStore();