@@ -59,6 +59,9 @@ function getOtherStudioActionLabel(action: OtherStudioAction): string {
59
59
return label ;
60
60
}
61
61
62
+ // Used to avoid triggering the edit listener when files are reloaded by an extension
63
+ const suppressEditListenerMap = new Map < string , boolean > ( ) ;
64
+
62
65
class StudioActions {
63
66
private uri : vscode . Uri ;
64
67
private api : AtelierAPI ;
@@ -86,10 +89,6 @@ class StudioActions {
86
89
outputChannel . appendLine ( errorText ) ;
87
90
outputChannel . show ( ) ;
88
91
}
89
- if ( userAction . reload ) {
90
- const document = vscode . window . activeTextEditor . document ;
91
- loadChanges ( [ currentFile ( document ) ] ) ;
92
- }
93
92
if ( config ( ) . studioActionDebugOutput ) {
94
93
outputChannel . appendLine ( JSON . stringify ( userAction ) ) ;
95
94
}
@@ -267,6 +266,14 @@ class StudioActions {
267
266
}
268
267
const actionToProcess = data . result . content . pop ( ) ;
269
268
269
+ if ( actionToProcess . reload ) {
270
+ const document = vscode . window . activeTextEditor . document ;
271
+ const file = currentFile ( document ) ;
272
+ // Avoid the reload triggering the edit listener here
273
+ suppressEditListenerMap . set ( file . uri . toString ( ) , true ) ;
274
+ await loadChanges ( [ file ] ) ;
275
+ }
276
+
270
277
// CSP pages should not have a progress bar
271
278
if ( actionToProcess . action === 2 ) {
272
279
resolve ( ) ;
@@ -359,6 +366,12 @@ class StudioActions {
359
366
label : getOtherStudioActionLabel ( action ) ,
360
367
} ;
361
368
if ( action === OtherStudioAction . AttemptedEdit ) {
369
+ // Check to see if this "attempted edit" was an action by this extension due to a reload.
370
+ // There's no way to detect at a higher level from the event.
371
+ if ( suppressEditListenerMap . has ( this . uri . toString ( ) ) ) {
372
+ suppressEditListenerMap . delete ( this . uri . toString ( ) ) ;
373
+ return ;
374
+ }
362
375
const query = "select * from %Atelier_v1_Utils.Extension_GetStatus(?)" ;
363
376
this . api . actionQuery ( query , [ this . name ] ) . then ( ( statusObj ) => {
364
377
const docStatus = statusObj . result . content . pop ( ) ;
0 commit comments