From 0ca60266c9cc1826dd7fb872fb306feb1d1ac296 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 17 Apr 2019 12:02:32 +0200 Subject: [PATCH] title control: add and use updateEditorLabels() --- .../browser/parts/editor/noTabsTitleControl.ts | 13 +++++++------ .../browser/parts/editor/tabsTitleControl.ts | 6 ++++++ .../workbench/browser/parts/editor/titleControl.ts | 6 ++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts index 29ea161b75f02..885211a42beec 100644 --- a/src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts @@ -145,12 +145,13 @@ export class NoTabsTitleControl extends TitleControl { this.redraw(); } - updateEditorLabel(editor?: IEditorInput): void { - if (!editor) { - editor = withNullAsUndefined(this.group.activeEditor); - } - if (editor) { - this.ifEditorIsActive(editor, () => this.redraw()); + updateEditorLabel(editor: IEditorInput): void { + this.ifEditorIsActive(editor, () => this.redraw()); + } + + updateEditorLabels(): void { + if (this.group.activeEditor) { + this.updateEditorLabel(this.group.activeEditor); // we only have the active one to update } } diff --git a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts index 005dd152f6206..919151455e1e1 100644 --- a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts @@ -360,6 +360,12 @@ export class TabsTitleControl extends TitleControl { updateEditorLabel(editor: IEditorInput): void { + // Update all labels to account for changes to tab labels + this.updateEditorLabels(); + } + + updateEditorLabels(): void { + // A change to a label requires to recompute all labels this.computeTabLabels(); diff --git a/src/vs/workbench/browser/parts/editor/titleControl.ts b/src/vs/workbench/browser/parts/editor/titleControl.ts index ad0a766f87f5d..fd79f843f1c5a 100644 --- a/src/vs/workbench/browser/parts/editor/titleControl.ts +++ b/src/vs/workbench/browser/parts/editor/titleControl.ts @@ -92,7 +92,7 @@ export abstract class TitleControl extends Themable { private registerListeners(): void { this._register(this.extensionService.onDidRegisterExtensions(() => this.updateEditorActionsToolbar())); - this._register(this.labelService.onDidChangeFormatters(() => this.updateEditorLabel())); + this._register(this.labelService.onDidChangeFormatters(() => this.updateEditorLabels())); } protected abstract create(parent: HTMLElement): void; @@ -342,7 +342,9 @@ export abstract class TitleControl extends Themable { abstract setActive(isActive: boolean): void; - abstract updateEditorLabel(editor?: IEditorInput): void; + abstract updateEditorLabel(editor: IEditorInput): void; + + abstract updateEditorLabels(): void; abstract updateEditorDirty(editor: IEditorInput): void;