@@ -295,94 +295,85 @@ export class StudioActions {
295
295
? [ type . toString ( ) , action . id , this . name , answer , msg ]
296
296
: [ type . toString ( ) , action . id , this . name , selectedText ] ;
297
297
298
- return vscode . window . withProgress (
299
- {
300
- cancellable : false ,
301
- location : vscode . ProgressLocation . Notification ,
302
- title : `Executing ${ afterUserAction ? "AfterUserAction" : "UserAction" } : ${ action . label } ` ,
303
- } ,
304
- ( ) => {
305
- return new Promise ( ( resolve , reject ) => {
306
- this . api
307
- . actionQuery ( query , parameters )
308
- . then ( async ( data ) => {
309
- if ( action . save && action . id != "6" /* No save for import list */ ) {
310
- await this . processSaveFlag ( action . save ) ;
311
- }
312
- if ( ! afterUserAction ) {
313
- outputConsole ( data . console ) ;
314
- }
315
- if ( ! data . result . content . length ) {
316
- // nothing to-do, just ignore it
317
- return ;
318
- }
319
- const actionToProcess = data . result . content . pop ( ) ;
298
+ if ( config ( ) . studioActionDebugOutput ) {
299
+ outputChannel . appendLine ( `${ query . slice ( 0 , query . indexOf ( "(" ) ) } (${ JSON . stringify ( parameters ) . slice ( 1 , - 1 ) } )` ) ;
300
+ }
320
301
321
- if ( actionToProcess . reload ) {
322
- // Avoid the reload triggering the edit listener here
323
- suppressEditListenerMap . set ( this . uri . toString ( ) , true ) ;
324
- await vscode . commands . executeCommand ( "workbench.action.files.revert" , this . uri ) ;
325
- }
302
+ return new Promise ( ( resolve , reject ) => {
303
+ this . api
304
+ . actionQuery ( query , parameters )
305
+ . then ( async ( data ) => {
306
+ if ( action . save && action . id != "6" /* No save for import list */ ) {
307
+ await this . processSaveFlag ( action . save ) ;
308
+ }
309
+ if ( ! afterUserAction ) {
310
+ outputConsole ( data . console ) ;
311
+ }
312
+ if ( ! data . result . content . length ) {
313
+ // Nothing to do. Most likely no source control class is enabled.
314
+ this . projectEditAnswer = "1" ;
315
+ return ;
316
+ }
317
+ const actionToProcess = data . result . content . pop ( ) ;
326
318
327
- // CSP pages should not have a progress bar
328
- if ( actionToProcess . action === 2 ) {
329
- resolve ( ) ;
330
- }
319
+ if ( actionToProcess . reload ) {
320
+ // Avoid the reload triggering the edit listener here
321
+ suppressEditListenerMap . set ( this . uri . toString ( ) , true ) ;
322
+ await vscode . commands . executeCommand ( "workbench.action.files.revert" , this . uri ) ;
323
+ }
331
324
332
- const attemptedEditLabel = getOtherStudioActionLabel ( OtherStudioAction . AttemptedEdit ) ;
333
- if ( afterUserAction && actionToProcess . errorText !== "" ) {
334
- if ( action . label === attemptedEditLabel ) {
335
- if ( this . name . toUpperCase ( ) . endsWith ( ".PRJ" ) ) {
336
- // Store the "answer" so the caller knows there was an error
337
- this . projectEditAnswer = "-1" ;
338
- } else if ( this . uri ) {
339
- // Only revert if we have a URI
340
- suppressEditListenerMap . set ( this . uri . toString ( ) , true ) ;
341
- await vscode . commands . executeCommand ( "workbench.action.files.revert" , this . uri ) ;
342
- }
343
- }
344
- outputChannel . appendLine ( actionToProcess . errorText ) ;
345
- outputChannel . show ( ) ;
325
+ const attemptedEditLabel = getOtherStudioActionLabel ( OtherStudioAction . AttemptedEdit ) ;
326
+ if ( afterUserAction && actionToProcess . errorText !== "" ) {
327
+ if ( action . label === attemptedEditLabel ) {
328
+ if ( this . name . toUpperCase ( ) . endsWith ( ".PRJ" ) ) {
329
+ // Store the "answer" so the caller knows there was an error
330
+ this . projectEditAnswer = "-1" ;
331
+ } else if ( this . uri ) {
332
+ // Only revert if we have a URI
333
+ suppressEditListenerMap . set ( this . uri . toString ( ) , true ) ;
334
+ await vscode . commands . executeCommand ( "workbench.action.files.revert" , this . uri ) ;
346
335
}
347
- if ( actionToProcess && ! afterUserAction ) {
348
- const answer = await this . processUserAction ( actionToProcess ) ;
349
- // call AfterUserAction only if there is a valid answer
350
- if ( action . label === attemptedEditLabel ) {
351
- if ( answer != "1" && this . uri ) {
352
- // Only revert if we have a URI
353
- suppressEditListenerMap . set ( this . uri . toString ( ) , true ) ;
354
- await vscode . commands . executeCommand ( "workbench.action.files.revert" , this . uri ) ;
355
- }
356
- if ( this . name . toUpperCase ( ) . endsWith ( ".PRJ" ) ) {
357
- // Store the answer. No answer means "allow the edit".
358
- this . projectEditAnswer = answer ?? "1" ;
359
- }
360
- }
361
- if ( answer ) {
362
- answer . msg || answer . msg === ""
363
- ? this . userAction ( action , true , answer . answer , answer . msg , type )
364
- : this . userAction ( action , true , answer , "" , type ) ;
365
- }
336
+ }
337
+ outputChannel . appendLine ( actionToProcess . errorText ) ;
338
+ outputChannel . show ( true ) ;
339
+ }
340
+ if ( actionToProcess && ! afterUserAction ) {
341
+ const answer = await this . processUserAction ( actionToProcess ) ;
342
+ // call AfterUserAction only if there is a valid answer
343
+ if ( action . label === attemptedEditLabel ) {
344
+ if ( answer != "1" && this . uri ) {
345
+ // Only revert if we have a URI
346
+ suppressEditListenerMap . set ( this . uri . toString ( ) , true ) ;
347
+ await vscode . commands . executeCommand ( "workbench.action.files.revert" , this . uri ) ;
366
348
}
367
- } )
368
- . then ( ( ) => resolve ( ) )
369
- . catch ( ( err ) => {
370
- outputChannel . appendLine (
371
- `Executing Studio Action "${ action . label } " on ${ this . api . config . host } :${ this . api . config . port } ${
372
- this . api . config . pathPrefix
373
- } [${ this . api . config . ns } ] failed${
374
- err . errorText && err . errorText !== "" ? " with the following error:" : "."
375
- } `
376
- ) ;
377
- if ( err . errorText && err . errorText !== "" ) {
378
- outputChannel . appendLine ( "\n" + err . errorText ) ;
349
+ if ( this . name . toUpperCase ( ) . endsWith ( ".PRJ" ) ) {
350
+ // Store the answer. No answer means "allow the edit".
351
+ this . projectEditAnswer = answer ?? "1" ;
379
352
}
380
- outputChannel . show ( ) ;
381
- reject ( ) ;
382
- } ) ;
353
+ }
354
+ if ( answer ) {
355
+ answer . msg || answer . msg === ""
356
+ ? this . userAction ( action , true , answer . answer , answer . msg , type )
357
+ : this . userAction ( action , true , answer , "" , type ) ;
358
+ }
359
+ }
360
+ } )
361
+ . then ( ( ) => resolve ( ) )
362
+ . catch ( ( err ) => {
363
+ outputChannel . appendLine (
364
+ `Executing Studio Action "${ action . label } " on ${ this . api . config . host } :${ this . api . config . port } ${
365
+ this . api . config . pathPrefix
366
+ } [${ this . api . config . ns } ] failed${
367
+ err . errorText && err . errorText !== "" ? " with the following error:" : "."
368
+ } `
369
+ ) ;
370
+ if ( err . errorText && err . errorText !== "" ) {
371
+ outputChannel . appendLine ( "\n" + err . errorText ) ;
372
+ }
373
+ outputChannel . show ( true ) ;
374
+ reject ( ) ;
383
375
} ) ;
384
- }
385
- ) ;
376
+ } ) ;
386
377
}
387
378
388
379
private prepareMenuItems ( menus , sourceControl : boolean ) : StudioAction [ ] {
@@ -501,7 +492,8 @@ export class StudioActions {
501
492
return this . api
502
493
. actionQuery ( "SELECT %Atelier_v1_Utils.Extension_ExtensionEnabled() AS Enabled" , [ ] )
503
494
. then ( ( data ) => data . result . content )
504
- . then ( ( content ) => ( content && content . length ? content [ 0 ] . Enabled : false ) ) ;
495
+ . then ( ( content ) => ( content && content . length ? content [ 0 ] ?. Enabled ?? false : false ) )
496
+ . catch ( ( ) => false ) ; // Treat any errors as "no source control"
505
497
}
506
498
507
499
public getServerInfo ( ) : { server : string ; namespace : string } {
@@ -576,7 +568,6 @@ export async function fireOtherStudioAction(action: OtherStudioAction, uri?: vsc
576
568
const studioActions = new StudioActions ( uri ) ;
577
569
return (
578
570
studioActions &&
579
- ( await studioActions . isSourceControlEnabled ( ) ) &&
580
571
! openCustomEditors . includes ( uri ?. toString ( ) ) && // The custom editor will handle all server-side source control interactions
581
572
studioActions . fireOtherStudioAction ( action , userAction )
582
573
) ;
0 commit comments