@@ -298,19 +298,17 @@ export abstract class AbstractContextKeyService implements IContextKeyService {
298298export class ContextKeyService extends AbstractContextKeyService implements IContextKeyService {
299299
300300 private _lastContextId : number ;
301- private _contexts : {
302- [ contextId : string ] : Context ;
303- } ;
301+ private readonly _contexts = new Map < number , Context > ( ) ;
304302
305303 private _toDispose : IDisposable [ ] = [ ] ;
306304
307305 constructor ( @IConfigurationService configurationService : IConfigurationService ) {
308306 super ( 0 ) ;
309307 this . _lastContextId = 0 ;
310- this . _contexts = Object . create ( null ) ;
308+
311309
312310 const myContext = new ConfigAwareContextValuesContainer ( this . _myContextId , configurationService , this . _onDidChangeContext ) ;
313- this . _contexts [ String ( this . _myContextId ) ] = myContext ;
311+ this . _contexts . set ( this . _myContextId , myContext ) ;
314312 this . _toDispose . push ( myContext ) ;
315313
316314 // Uncomment this to see the contexts continuously logged
@@ -334,23 +332,22 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
334332 if ( this . _isDisposed ) {
335333 return NullContext . INSTANCE ;
336334 }
337- return this . _contexts [ String ( contextId ) ] ;
335+ return this . _contexts . get ( contextId ) || NullContext . INSTANCE ;
338336 }
339337
340338 public createChildContext ( parentContextId : number = this . _myContextId ) : number {
341339 if ( this . _isDisposed ) {
342340 throw new Error ( `ContextKeyService has been disposed` ) ;
343341 }
344342 let id = ( ++ this . _lastContextId ) ;
345- this . _contexts [ String ( id ) ] = new Context ( id , this . getContextValuesContainer ( parentContextId ) ) ;
343+ this . _contexts . set ( id , new Context ( id , this . getContextValuesContainer ( parentContextId ) ) ) ;
346344 return id ;
347345 }
348346
349347 public disposeContext ( contextId : number ) : void {
350- if ( this . _isDisposed ) {
351- return ;
348+ if ( ! this . _isDisposed ) {
349+ this . _contexts . delete ( contextId ) ;
352350 }
353- delete this . _contexts [ String ( contextId ) ] ;
354351 }
355352}
356353
0 commit comments