@@ -176,6 +176,9 @@ export class ExtensionServiceImpl extends WithEventBus implements ExtensionServi
176176 private isExtProcessWaitingForRestart : ERestartPolicy | undefined ;
177177 private pCrashMessageModel : MayCancelablePromise < string | undefined > | undefined ;
178178
179+ // 是否正在显示插件重启的 loading 状态
180+ private isProgressShowing = false ;
181+
179182 // 针对 activationEvents 为 * 的插件
180183 public eagerExtensionsActivated : Deferred < void > = new Deferred ( ) ;
181184
@@ -383,6 +386,7 @@ export class ExtensionServiceImpl extends WithEventBus implements ExtensionServi
383386 this . logger . log ( '[ext-restart]: ext process restart canceled' ) ;
384387 this . isExtProcessRestarting = false ;
385388 this . isExtProcessWaitingForRestart = undefined ;
389+ this . isProgressShowing = false ;
386390 } ) ;
387391
388392 try {
@@ -393,6 +397,7 @@ export class ExtensionServiceImpl extends WithEventBus implements ExtensionServi
393397
394398 this . isExtProcessRestarting = false ;
395399 this . isExtProcessWaitingForRestart = undefined ;
400+ this . isProgressShowing = false ;
396401
397402 this . disposeAllOverlayWindow ( ) ;
398403 } ;
@@ -412,6 +417,12 @@ export class ExtensionServiceImpl extends WithEventBus implements ExtensionServi
412417 break ;
413418 }
414419 case ERestartPolicy . Always :
420+ if ( this . isProgressShowing ) {
421+ this . logger . log ( '[ext-restart]: progress is already showing, skip' ) ;
422+ return ;
423+ }
424+
425+ this . isProgressShowing = true ;
415426 await this . progressService . withProgress (
416427 {
417428 location : ProgressLocation . Notification ,
@@ -429,9 +440,7 @@ export class ExtensionServiceImpl extends WithEventBus implements ExtensionServi
429440 ] ,
430441 } ,
431442 async ( ) => {
432- if ( this . extProcessRestartPromise ) {
433- this . extProcessRestartPromise . cancel ( ) ;
434- }
443+ // doRestart 存在严重的副作用且不可 Cancel,因此单次重启只允许执行一次
435444 this . extProcessRestartPromise = createCancelablePromise ( doRestart ) ;
436445 await this . extProcessRestartPromise ;
437446 } ,
@@ -769,13 +778,11 @@ export class ExtensionServiceImpl extends WithEventBus implements ExtensionServi
769778 private async rerunSumiViewExtensionContributes ( ) {
770779 const { activatedViewExtensionMap } = this . viewExtensionService ;
771780 const extensionPaths = Array . from ( activatedViewExtensionMap . keys ( ) ) ;
772-
773781 await Promise . all (
774782 extensionPaths . map ( ( path ) => {
775783 const extension = this . extensionInstanceManageService . getExtensionInstanceByPath ( path ) ;
776784 if ( extension ) {
777785 extension . initialize ( ) ;
778- this . contributesService . register ( extension . id , extension . contributes ) ;
779786 this . sumiContributesService . register ( extension . id , extension . packageJSON . sumiContributes || { } ) ;
780787 }
781788 } ) ,
0 commit comments