Skip to content

Commit 9ef31ac

Browse files
authored
1 parent a8ef81e commit 9ef31ac

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/vs/workbench/contrib/extensions/browser/fileBasedRecommendations.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,24 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
151151
this._register(disposableTimeout(() => this.promptRecommendations(uri, model), 0));
152152
}
153153

154+
private promptRecommendations(uri: URI, model: ITextModel): void {
155+
if (this.promptImportantRecommendations(uri, model)) {
156+
return;
157+
}
158+
159+
this.promptRecommendedExtensionForFileExtension(uri, extname(uri).toLowerCase());
160+
}
161+
154162
/**
155163
* Prompt the user to either install the recommended extension for the file type in the current editor model
156164
* or prompt to search the marketplace if it has extensions that can support the file type
157165
*/
158-
private promptRecommendations(uri: URI, model: ITextModel, extensionRecommendations?: IStringDictionary<IFileOpenCondition[]>): void {
166+
private promptImportantRecommendations(uri: URI, model: ITextModel, extensionRecommendations?: IStringDictionary<IFileOpenCondition[]>): boolean {
159167
const pattern = extname(uri).toLowerCase();
160168
extensionRecommendations = extensionRecommendations ?? this.recommendationsByPattern.get(pattern) ?? this.fileOpenRecommendations;
161169
const extensionRecommendationEntries = Object.entries(extensionRecommendations);
162170
if (extensionRecommendationEntries.length === 0) {
163-
return;
171+
return false;
164172
}
165173

166174
const processedPathGlobs = new Map<string, boolean>();
@@ -246,10 +254,6 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
246254
}
247255
}
248256

249-
if (Object.keys(matchedRecommendations).length) {
250-
this.promptFromRecommendations(uri, model, matchedRecommendations);
251-
}
252-
253257
this.recommendationsByPattern.set(pattern, recommendationsByPattern);
254258
if (Object.keys(unmatchedRecommendations).length) {
255259
if (listenOnLanguageChange) {
@@ -258,14 +262,21 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
258262
// re-schedule this bit of the operation to be off the critical path - in case glob-match is slow
259263
disposables.add(disposableTimeout(() => {
260264
if (!disposables.isDisposed) {
261-
this.promptRecommendations(uri, model, unmatchedRecommendations);
265+
this.promptImportantRecommendations(uri, model, unmatchedRecommendations);
262266
disposables.dispose();
263267
}
264268
}, 0));
265269
}));
266270
disposables.add(model.onWillDispose(() => disposables.dispose()));
267271
}
268272
}
273+
274+
if (Object.keys(matchedRecommendations).length) {
275+
this.promptFromRecommendations(uri, model, matchedRecommendations);
276+
return true;
277+
}
278+
279+
return false;
269280
}
270281

271282
private promptFromRecommendations(uri: URI, model: ITextModel, extensionRecommendations: IStringDictionary<IFileOpenCondition[]>): void {
@@ -304,8 +315,6 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
304315
this.promptRecommendedExtensionForFileType(languageName && isImportantRecommendationForLanguage && language !== PLAINTEXT_LANGUAGE_ID ? localize('languageName', "{0} language", languageName) : basename(uri), language, [...importantRecommendations])) {
305316
return;
306317
}
307-
308-
this.promptRecommendedExtensionForFileExtension(uri, extname(uri).toLowerCase());
309318
}
310319

311320
private promptRecommendedExtensionForFileType(name: string, language: string, recommendations: string[]): boolean {

0 commit comments

Comments
 (0)