@@ -298,6 +298,26 @@ async function activateCodefileOverlays(
298
298
async function createYamlExtensionPrompt ( ) : Promise < void > {
299
299
const settings = PromptSettings . instance
300
300
301
+ /**
302
+ * Prompt the user to install the YAML plugin when AWSTemplateFormatVersion becomes available as a top level key
303
+ * in the document
304
+ * @param event An vscode text document change event
305
+ * @returns nothing
306
+ */
307
+ async function promptOnAWSTemplateFormatVersion (
308
+ event : vscode . TextDocumentChangeEvent ,
309
+ yamlPromptDisposables : vscode . Disposable [ ]
310
+ ) : Promise < void > {
311
+ for ( const change of event . contentChanges ) {
312
+ const changedLine = event . document . lineAt ( change . range . start . line )
313
+ if ( changedLine . text . includes ( 'AWSTemplateFormatVersion' ) ) {
314
+ promptInstallYamlPlugin ( yamlPromptDisposables )
315
+ return
316
+ }
317
+ }
318
+ return
319
+ }
320
+
301
321
// Show this only in VSCode since other VSCode-like IDEs (e.g. Theia) may
302
322
// not have a marketplace or contain the YAML plugin.
303
323
if (
@@ -327,23 +347,6 @@ async function createYamlExtensionPrompt(): Promise<void> {
327
347
yamlPromptDisposables
328
348
)
329
349
330
- /**
331
- * Prompt the user to install the YAML plugin when AWSTemplateFormatVersion becomes available as a top level key
332
- * in the document
333
- * @param event An vscode text document change event
334
- * @returns nothing
335
- */
336
- async function promptOnAWSTemplateFormatVersion ( event : vscode . TextDocumentChangeEvent ) : Promise < void > {
337
- for ( const change of event . contentChanges ) {
338
- const changedLine = event . document . lineAt ( change . range . start . line )
339
- if ( changedLine . text . includes ( 'AWSTemplateFormatVersion' ) ) {
340
- promptInstallYamlPlugin ( yamlPromptDisposables )
341
- return
342
- }
343
- }
344
- return
345
- }
346
-
347
350
const promptNotifications = new Map < string , Promise < unknown > > ( )
348
351
vscode . workspace . onDidChangeTextDocument (
349
352
( event : vscode . TextDocumentChangeEvent ) => {
@@ -355,7 +358,9 @@ async function createYamlExtensionPrompt(): Promise<void> {
355
358
) {
356
359
promptNotifications . set (
357
360
uri ,
358
- promptOnAWSTemplateFormatVersion ( event ) . finally ( ( ) => promptNotifications . delete ( uri ) )
361
+ promptOnAWSTemplateFormatVersion ( event , yamlPromptDisposables ) . finally ( ( ) =>
362
+ promptNotifications . delete ( uri )
363
+ )
359
364
)
360
365
}
361
366
} ,
0 commit comments