55
66import { localize } from 'vs/nls' ;
77import { URI } from 'vs/base/common/uri' ;
8- import { IDisposable } from 'vs/base/common/lifecycle' ;
8+ import { IDisposable , Disposable } from 'vs/base/common/lifecycle' ;
99import * as paths from 'vs/base/common/path' ;
10- import { Event , Emitter } from 'vs/base/common/event' ;
10+ import { Emitter } from 'vs/base/common/event' ;
1111import { Extensions as WorkbenchExtensions , IWorkbenchContributionsRegistry , IWorkbenchContribution } from 'vs/workbench/common/contributions' ;
1212import { Registry } from 'vs/platform/registry/common/platform' ;
1313import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
@@ -16,7 +16,7 @@ import { isEqual, basenameOrAuthority, basename, joinPath, dirname } from 'vs/ba
1616import { tildify , getPathLabel } from 'vs/base/common/labels' ;
1717import { ltrim , endsWith } from 'vs/base/common/strings' ;
1818import { IWorkspaceIdentifier , ISingleFolderWorkspaceIdentifier , isSingleFolderWorkspaceIdentifier , WORKSPACE_EXTENSION , toWorkspaceIdentifier , isWorkspaceIdentifier , isUntitledWorkspace } from 'vs/platform/workspaces/common/workspaces' ;
19- import { ILabelService , ResourceLabelFormatter , ResourceLabelFormatting } from 'vs/platform/label/common/label' ;
19+ import { ILabelService , ResourceLabelFormatter , ResourceLabelFormatting , IFormatterChangeEvent } from 'vs/platform/label/common/label' ;
2020import { ExtensionsRegistry } from 'vs/workbench/services/extensions/common/extensionsRegistry' ;
2121import { match } from 'vs/base/common/glob' ;
2222import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle' ;
@@ -89,19 +89,20 @@ class ResourceLabelFormattersHandler implements IWorkbenchContribution {
8989}
9090Registry . as < IWorkbenchContributionsRegistry > ( WorkbenchExtensions . Workbench ) . registerWorkbenchContribution ( ResourceLabelFormattersHandler , LifecyclePhase . Restored ) ;
9191
92- export class LabelService implements ILabelService {
92+ export class LabelService extends Disposable implements ILabelService {
93+
9394 _serviceBrand : undefined ;
9495
9596 private formatters : ResourceLabelFormatter [ ] = [ ] ;
96- private readonly _onDidChangeFormatters = new Emitter < void > ( ) ;
97+
98+ private readonly _onDidChangeFormatters = this . _register ( new Emitter < IFormatterChangeEvent > ( ) ) ;
99+ readonly onDidChangeFormatters = this . _onDidChangeFormatters . event ;
97100
98101 constructor (
99102 @IEnvironmentService private readonly environmentService : IEnvironmentService ,
100103 @IWorkspaceContextService private readonly contextService : IWorkspaceContextService ,
101- ) { }
102-
103- get onDidChangeFormatters ( ) : Event < void > {
104- return this . _onDidChangeFormatters . event ;
104+ ) {
105+ super ( ) ;
105106 }
106107
107108 findFormatting ( resource : URI ) : ResourceLabelFormatting | undefined {
@@ -226,12 +227,12 @@ export class LabelService implements ILabelService {
226227
227228 registerFormatter ( formatter : ResourceLabelFormatter ) : IDisposable {
228229 this . formatters . push ( formatter ) ;
229- this . _onDidChangeFormatters . fire ( ) ;
230+ this . _onDidChangeFormatters . fire ( { scheme : formatter . scheme } ) ;
230231
231232 return {
232233 dispose : ( ) => {
233234 this . formatters = this . formatters . filter ( f => f !== formatter ) ;
234- this . _onDidChangeFormatters . fire ( ) ;
235+ this . _onDidChangeFormatters . fire ( { scheme : formatter . scheme } ) ;
235236 }
236237 } ;
237238 }
0 commit comments