@@ -58,6 +58,7 @@ function hasPlainTextFallback(modeInfo, filename) {
5858
5959class LanguageModeRecommendations {
6060 notifiedKeywords = new Set ( ) ;
61+ pendingKeywords = new Set ( ) ;
6162 availabilityCache = new Map ( ) ;
6263
6364 async getPluginAvailability ( keyword ) {
@@ -73,9 +74,9 @@ class LanguageModeRecommendations {
7374 ) ,
7475 ) ,
7576 )
76- . then ( ( response ) => response . json ( ) )
77+ . then ( ( response ) => ( response . ok ? response . json ( ) : [ ] ) )
7778 . then ( ( plugins ) => Array . isArray ( plugins ) && plugins . length > 0 )
78- . catch ( ( ) => true ) ;
79+ . catch ( ( ) => false ) ;
7980
8081 this . availabilityCache . set ( keyword , availability ) ;
8182 return availability ;
@@ -88,11 +89,25 @@ class LanguageModeRecommendations {
8889 if ( ! hasPlainTextFallback ( modeInfo , filename ) ) return ;
8990
9091 const keyword = getSearchKeyword ( filename ) ;
91- if ( ! keyword || this . notifiedKeywords . has ( keyword ) ) return ;
92-
93- this . notifiedKeywords . add ( keyword ) ;
92+ if (
93+ ! keyword ||
94+ this . notifiedKeywords . has ( keyword ) ||
95+ this . pendingKeywords . has ( keyword )
96+ ) {
97+ return ;
98+ }
9499
95- void this . showRecommendation ( keyword ) ;
100+ this . pendingKeywords . add ( keyword ) ;
101+ void this . showRecommendation ( keyword )
102+ . then ( ( ) => {
103+ this . notifiedKeywords . add ( keyword ) ;
104+ } )
105+ . catch ( ( error ) => {
106+ console . warn ( "Failed to show extension recommendation." , error ) ;
107+ } )
108+ . finally ( ( ) => {
109+ this . pendingKeywords . delete ( keyword ) ;
110+ } ) ;
96111 }
97112
98113 async showRecommendation ( keyword ) {
0 commit comments