@@ -546,23 +546,6 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
546
546
}
547
547
548
548
private async _deltaExtensions ( _toAdd : IExtension [ ] , _toRemove : string [ ] | IExtension [ ] ) : Promise < void > {
549
- const toAdd : IExtensionDescription [ ] = [ ] ;
550
- for ( let i = 0 , len = _toAdd . length ; i < len ; i ++ ) {
551
- const extension = _toAdd [ i ] ;
552
-
553
- const extensionDescription = await this . _scanSingleExtension ( extension ) ;
554
- if ( ! extensionDescription ) {
555
- // could not scan extension...
556
- continue ;
557
- }
558
-
559
- if ( ! this . canAddExtension ( extensionDescription ) ) {
560
- continue ;
561
- }
562
-
563
- toAdd . push ( extensionDescription ) ;
564
- }
565
-
566
549
let toRemove : IExtensionDescription [ ] = [ ] ;
567
550
for ( let i = 0 , len = _toRemove . length ; i < len ; i ++ ) {
568
551
const extensionOrId = _toRemove [ i ] ;
@@ -587,6 +570,23 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
587
570
toRemove . push ( extensionDescription ) ;
588
571
}
589
572
573
+ const toAdd : IExtensionDescription [ ] = [ ] ;
574
+ for ( let i = 0 , len = _toAdd . length ; i < len ; i ++ ) {
575
+ const extension = _toAdd [ i ] ;
576
+
577
+ const extensionDescription = await this . _scanSingleExtension ( extension ) ;
578
+ if ( ! extensionDescription ) {
579
+ // could not scan extension...
580
+ continue ;
581
+ }
582
+
583
+ if ( ! this . _canAddExtension ( extensionDescription , toRemove ) ) {
584
+ continue ;
585
+ }
586
+
587
+ toAdd . push ( extensionDescription ) ;
588
+ }
589
+
590
590
if ( toAdd . length === 0 && toRemove . length === 0 ) {
591
591
return ;
592
592
}
@@ -643,15 +643,19 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
643
643
}
644
644
645
645
public canAddExtension ( extension : IExtensionDescription ) : boolean {
646
- const existing = this . _registry . getExtensionDescription ( extension . identifier ) ;
647
- if ( existing ) {
648
- // this extension is already running (most likely at a different version)
649
- return false ;
650
- }
646
+ return this . _canAddExtension ( extension , [ ] ) ;
647
+ }
651
648
652
- // Check if extension is renamed
653
- if ( extension . uuid && this . _registry . getAllExtensionDescriptions ( ) . some ( e => e . uuid === extension . uuid ) ) {
654
- return false ;
649
+ private _canAddExtension ( extension : IExtensionDescription , extensionsBeingRemoved : IExtensionDescription [ ] ) : boolean {
650
+ // (Also check for renamed extensions)
651
+ const existing = this . _registry . getExtensionDescriptionByIdOrUUID ( extension . identifier , extension . id ) ;
652
+ if ( existing ) {
653
+ // This extension is already known (most likely at a different version)
654
+ // so it cannot be added again unless it is removed first
655
+ const isBeingRemoved = extensionsBeingRemoved . some ( ( extensionDescription ) => ExtensionIdentifier . equals ( extension . identifier , extensionDescription . identifier ) ) ;
656
+ if ( ! isBeingRemoved ) {
657
+ return false ;
658
+ }
655
659
}
656
660
657
661
const extensionKind = this . _getExtensionKind ( extension ) ;
@@ -667,7 +671,7 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
667
671
public canRemoveExtension ( extension : IExtensionDescription ) : boolean {
668
672
const extensionDescription = this . _registry . getExtensionDescription ( extension . identifier ) ;
669
673
if ( ! extensionDescription ) {
670
- // ignore removing an extension which is not running
674
+ // Can't remove an extension that is unknown!
671
675
return false ;
672
676
}
673
677
0 commit comments