mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
labels - handle file service changes better (fix #91833)
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as paths from 'vs/base/common/path';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry, IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
@@ -16,7 +16,7 @@ import { isEqual, basenameOrAuthority, basename, joinPath, dirname } from 'vs/ba
|
||||
import { tildify, getPathLabel } from 'vs/base/common/labels';
|
||||
import { ltrim, endsWith } from 'vs/base/common/strings';
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, WORKSPACE_EXTENSION, toWorkspaceIdentifier, isWorkspaceIdentifier, isUntitledWorkspace } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ILabelService, ResourceLabelFormatter, ResourceLabelFormatting } from 'vs/platform/label/common/label';
|
||||
import { ILabelService, ResourceLabelFormatter, ResourceLabelFormatting, IFormatterChangeEvent } from 'vs/platform/label/common/label';
|
||||
import { ExtensionsRegistry } from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
||||
import { match } from 'vs/base/common/glob';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
@@ -89,19 +89,20 @@ class ResourceLabelFormattersHandler implements IWorkbenchContribution {
|
||||
}
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ResourceLabelFormattersHandler, LifecyclePhase.Restored);
|
||||
|
||||
export class LabelService implements ILabelService {
|
||||
export class LabelService extends Disposable implements ILabelService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private formatters: ResourceLabelFormatter[] = [];
|
||||
private readonly _onDidChangeFormatters = new Emitter<void>();
|
||||
|
||||
private readonly _onDidChangeFormatters = this._register(new Emitter<IFormatterChangeEvent>());
|
||||
readonly onDidChangeFormatters = this._onDidChangeFormatters.event;
|
||||
|
||||
constructor(
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
) { }
|
||||
|
||||
get onDidChangeFormatters(): Event<void> {
|
||||
return this._onDidChangeFormatters.event;
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
findFormatting(resource: URI): ResourceLabelFormatting | undefined {
|
||||
@@ -226,12 +227,12 @@ export class LabelService implements ILabelService {
|
||||
|
||||
registerFormatter(formatter: ResourceLabelFormatter): IDisposable {
|
||||
this.formatters.push(formatter);
|
||||
this._onDidChangeFormatters.fire();
|
||||
this._onDidChangeFormatters.fire({ scheme: formatter.scheme });
|
||||
|
||||
return {
|
||||
dispose: () => {
|
||||
this.formatters = this.formatters.filter(f => f !== formatter);
|
||||
this._onDidChangeFormatters.fire();
|
||||
this._onDidChangeFormatters.fire({ scheme: formatter.scheme });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user