@@ -21,7 +21,9 @@ debug.log = log.debug.bind(log);
2121
2222import MDBExtensionController from './mdbExtensionController' ;
2323
24- let mdbExtension : MDBExtensionController ;
24+ let mdbExtension : MDBExtensionController | undefined ;
25+
26+ const isUnderTest = process . env . MDB_IS_TEST === 'true' ;
2527
2628// Called when our extension is activated.
2729// See "activationEvents" in `package.json` for the events that cause activation.
@@ -51,13 +53,24 @@ export async function activate(
5153 } ,
5254 } ) ;
5355
54- mdbExtension = new MDBExtensionController ( context , {
55- shouldTrackTelemetry : true ,
56- } ) ;
57- await mdbExtension . activate ( ) ;
56+ // Solution to VSCODE-700. If we are running tests, don't activate the extension.
57+ // This avoids registering multiple providers when running the tests, which causes errors in recent versions of vscode.
58+ if ( isUnderTest ) {
59+ log . info (
60+ 'Skipping MDBExtensionController activation because MDB_IS_TEST is set.' ,
61+ ) ;
62+ return ;
63+ }
5864
59- // Add our extension to a list of disposables for when we are deactivated.
60- context . subscriptions . push ( mdbExtension ) ;
65+ if ( ! mdbExtension ) {
66+ mdbExtension = new MDBExtensionController ( context , {
67+ shouldTrackTelemetry : true ,
68+ } ) ;
69+ await mdbExtension . activate ( ) ;
70+
71+ // Add our extension to a list of disposables for when we are deactivated.
72+ context . subscriptions . push ( mdbExtension ) ;
73+ }
6174}
6275
6376// Called when our extension is deactivated.
0 commit comments