55
66import { Event , Emitter } from 'vs/base/common/event' ;
77import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
8- import { IDisposable , dispose } from 'vs/base/common/lifecycle' ;
8+ import { DisposableStore } from 'vs/base/common/lifecycle' ;
99import { IExplorerService , IEditableData , IFilesConfiguration , SortOrder , SortOrderConfiguration } from 'vs/workbench/contrib/files/common/files' ;
1010import { ExplorerItem , ExplorerModel } from 'vs/workbench/contrib/files/common/explorerModel' ;
1111import { URI } from 'vs/base/common/uri' ;
@@ -36,7 +36,7 @@ export class ExplorerService implements IExplorerService {
3636 private _onDidChangeEditable = new Emitter < ExplorerItem > ( ) ;
3737 private _onDidSelectResource = new Emitter < { resource ?: URI , reveal ?: boolean } > ( ) ;
3838 private _onDidCopyItems = new Emitter < { items : ExplorerItem [ ] , cut : boolean , previouslyCutItems : ExplorerItem [ ] | undefined } > ( ) ;
39- private disposables : IDisposable [ ] = [ ] ;
39+ private readonly disposables = new DisposableStore ( ) ;
4040 private editable : { stat : ExplorerItem , data : IEditableData } | undefined ;
4141 private _sortOrder : SortOrder ;
4242 private cutItems : ExplorerItem [ ] | undefined ;
@@ -88,18 +88,18 @@ export class ExplorerService implements IExplorerService {
8888 ( root ?: URI ) => getFileEventsExcludes ( this . configurationService , root ) ,
8989 ( event : IConfigurationChangeEvent ) => event . affectsConfiguration ( FILES_EXCLUDE_CONFIG )
9090 ) ;
91- this . disposables . push ( fileEventsFilter ) ;
91+ this . disposables . add ( fileEventsFilter ) ;
9292
9393 return fileEventsFilter ;
9494 }
9595
9696 @memoize get model ( ) : ExplorerModel {
9797 const model = new ExplorerModel ( this . contextService ) ;
98- this . disposables . push ( model ) ;
99- this . disposables . push ( this . fileService . onAfterOperation ( e => this . onFileOperation ( e ) ) ) ;
100- this . disposables . push ( this . fileService . onFileChanges ( e => this . onFileChanges ( e ) ) ) ;
101- this . disposables . push ( this . configurationService . onDidChangeConfiguration ( e => this . onConfigurationUpdated ( this . configurationService . getValue < IFilesConfiguration > ( ) ) ) ) ;
102- this . disposables . push ( this . fileService . onDidChangeFileSystemProviderRegistrations ( e => {
98+ this . disposables . add ( model ) ;
99+ this . disposables . add ( this . fileService . onAfterOperation ( e => this . onFileOperation ( e ) ) ) ;
100+ this . disposables . add ( this . fileService . onFileChanges ( e => this . onFileChanges ( e ) ) ) ;
101+ this . disposables . add ( this . configurationService . onDidChangeConfiguration ( e => this . onConfigurationUpdated ( this . configurationService . getValue < IFilesConfiguration > ( ) ) ) ) ;
102+ this . disposables . add ( this . fileService . onDidChangeFileSystemProviderRegistrations ( e => {
103103 if ( e . added && this . fileSystemProviderSchemes . has ( e . scheme ) ) {
104104 // A file system provider got re-registered, we should update all file stats since they might change (got read-only)
105105 this . model . roots . forEach ( r => r . forgetChildren ( ) ) ;
@@ -108,7 +108,7 @@ export class ExplorerService implements IExplorerService {
108108 this . fileSystemProviderSchemes . add ( e . scheme ) ;
109109 }
110110 } ) ) ;
111- this . disposables . push ( model . onDidChangeRoots ( ( ) => this . _onDidChangeRoots . fire ( ) ) ) ;
111+ this . disposables . add ( model . onDidChangeRoots ( ( ) => this . _onDidChangeRoots . fire ( ) ) ) ;
112112
113113 return model ;
114114 }
@@ -380,6 +380,6 @@ export class ExplorerService implements IExplorerService {
380380 }
381381
382382 dispose ( ) : void {
383- dispose ( this . disposables ) ;
383+ this . disposables . dispose ( ) ;
384384 }
385385}
0 commit comments