提交 b069dbe0 编写于 作者: B Benjamin Pasero

Tab decorations need to update scrollbar (fix #112799)

上级 e588e04b
...@@ -100,6 +100,10 @@ export const DEFAULT_LABELS_CONTAINER: IResourceLabelsContainer = { ...@@ -100,6 +100,10 @@ export const DEFAULT_LABELS_CONTAINER: IResourceLabelsContainer = {
}; };
export class ResourceLabels extends Disposable { export class ResourceLabels extends Disposable {
private _onDidChangeDecorations = this._register(new Emitter<void>());
readonly onDidChangeDecorations = this._onDidChangeDecorations.event;
private widgets: ResourceLabelWidget[] = []; private widgets: ResourceLabelWidget[] = [];
private labels: IResourceLabel[] = []; private labels: IResourceLabel[] = [];
...@@ -148,7 +152,18 @@ export class ResourceLabels extends Disposable { ...@@ -148,7 +152,18 @@ export class ResourceLabels extends Disposable {
})); }));
// notify when file decoration changes // notify when file decoration changes
this._register(this.decorationsService.onDidChangeDecorations(e => this.widgets.forEach(widget => widget.notifyFileDecorationsChanges(e)))); this._register(this.decorationsService.onDidChangeDecorations(e => {
let notifyDidChangeDecorations = false;
this.widgets.forEach(widget => {
if (widget.notifyFileDecorationsChanges(e)) {
notifyDidChangeDecorations = true;
}
});
if (notifyDidChangeDecorations) {
this._onDidChangeDecorations.fire();
}
}));
// notify when theme changes // notify when theme changes
this._register(this.themeService.onDidColorThemeChange(() => this.widgets.forEach(widget => widget.notifyThemeChange()))); this._register(this.themeService.onDidColorThemeChange(() => this.widgets.forEach(widget => widget.notifyThemeChange())));
...@@ -311,19 +326,21 @@ class ResourceLabelWidget extends IconLabel { ...@@ -311,19 +326,21 @@ class ResourceLabelWidget extends IconLabel {
} }
} }
notifyFileDecorationsChanges(e: IResourceDecorationChangeEvent): void { notifyFileDecorationsChanges(e: IResourceDecorationChangeEvent): boolean {
if (!this.options) { if (!this.options) {
return; return false;
} }
const resource = toResource(this.label); const resource = toResource(this.label);
if (!resource) { if (!resource) {
return; return false;
} }
if (this.options.fileDecorations && e.affectsResource(resource)) { if (this.options.fileDecorations && e.affectsResource(resource)) {
this.render(false); return this.render(false);
} }
return false;
} }
notifyExtensionsRegistered(): void { notifyExtensionsRegistered(): void {
...@@ -465,7 +482,7 @@ class ResourceLabelWidget extends IconLabel { ...@@ -465,7 +482,7 @@ class ResourceLabelWidget extends IconLabel {
this.setLabel(''); this.setLabel('');
} }
private render(clearIconCache: boolean): void { private render(clearIconCache: boolean): boolean {
if (this.isHidden) { if (this.isHidden) {
if (!this.needsRedraw) { if (!this.needsRedraw) {
this.needsRedraw = clearIconCache ? Redraw.Full : Redraw.Basic; this.needsRedraw = clearIconCache ? Redraw.Full : Redraw.Basic;
...@@ -475,7 +492,7 @@ class ResourceLabelWidget extends IconLabel { ...@@ -475,7 +492,7 @@ class ResourceLabelWidget extends IconLabel {
this.needsRedraw = Redraw.Full; this.needsRedraw = Redraw.Full;
} }
return; return false;
} }
if (this.label) { if (this.label) {
...@@ -492,7 +509,7 @@ class ResourceLabelWidget extends IconLabel { ...@@ -492,7 +509,7 @@ class ResourceLabelWidget extends IconLabel {
} }
if (!this.label) { if (!this.label) {
return; return false;
} }
this.renderDisposables.clear(); this.renderDisposables.clear();
...@@ -558,6 +575,8 @@ class ResourceLabelWidget extends IconLabel { ...@@ -558,6 +575,8 @@ class ResourceLabelWidget extends IconLabel {
this.setLabel(label || '', this.label.description, iconLabelOptions); this.setLabel(label || '', this.label.description, iconLabelOptions);
this._onDidRender.fire(); this._onDidRender.fire();
return true;
} }
dispose(): void { dispose(): void {
......
...@@ -129,6 +129,9 @@ export class TabsTitleControl extends TitleControl { ...@@ -129,6 +129,9 @@ export class TabsTitleControl extends TitleControl {
// If we are connected to remote, this accounts for the // If we are connected to remote, this accounts for the
// remote OS. // remote OS.
(async () => this.path = await this.pathService.path)(); (async () => this.path = await this.pathService.path)();
// React to decorations changing for our resource labels
this._register(this.tabResourceLabels.onDidChangeDecorations(() => this.doHandleDecorationsChange()));
} }
protected create(parent: HTMLElement): void { protected create(parent: HTMLElement): void {
...@@ -161,7 +164,7 @@ export class TabsTitleControl extends TitleControl { ...@@ -161,7 +164,7 @@ export class TabsTitleControl extends TitleControl {
// Editor Actions Toolbar // Editor Actions Toolbar
this.createEditorActionsToolBar(this.editorToolbarContainer); this.createEditorActionsToolBar(this.editorToolbarContainer);
// Breadcrumbs (are on a separate row below tabs and actions) // Breadcrumbs
const breadcrumbsContainer = document.createElement('div'); const breadcrumbsContainer = document.createElement('div');
breadcrumbsContainer.classList.add('tabs-breadcrumbs'); breadcrumbsContainer.classList.add('tabs-breadcrumbs');
this.titleContainer.appendChild(breadcrumbsContainer); this.titleContainer.appendChild(breadcrumbsContainer);
...@@ -380,6 +383,13 @@ export class TabsTitleControl extends TitleControl { ...@@ -380,6 +383,13 @@ export class TabsTitleControl extends TitleControl {
})); }));
} }
private doHandleDecorationsChange(): void {
// A change to decorations potentially has an impact on the size of tabs
// so we need to trigger a layout in that case to adjust things
this.layout(this.dimensions);
}
protected updateEditorActionsToolbar(): void { protected updateEditorActionsToolbar(): void {
super.updateEditorActionsToolbar(); super.updateEditorActionsToolbar();
...@@ -611,7 +621,6 @@ export class TabsTitleControl extends TitleControl { ...@@ -611,7 +621,6 @@ export class TabsTitleControl extends TitleControl {
// Tab Editor Label // Tab Editor Label
const editorLabel = this.tabResourceLabels.create(tabContainer); const editorLabel = this.tabResourceLabels.create(tabContainer);
const editorLabelRenderDisposable = editorLabel.onDidRender(() => this.layout(this.dimensions));
// Tab Actions // Tab Actions
const tabActionsContainer = document.createElement('div'); const tabActionsContainer = document.createElement('div');
...@@ -637,7 +646,7 @@ export class TabsTitleControl extends TitleControl { ...@@ -637,7 +646,7 @@ export class TabsTitleControl extends TitleControl {
// Eventing // Eventing
const eventsDisposable = this.registerTabListeners(tabContainer, index, tabsContainer, tabsScrollbar); const eventsDisposable = this.registerTabListeners(tabContainer, index, tabsContainer, tabsScrollbar);
this.tabDisposables.push(combinedDisposable(eventsDisposable, tabActionBarDisposable, tabActionRunner, editorLabel, editorLabelRenderDisposable)); this.tabDisposables.push(combinedDisposable(eventsDisposable, tabActionBarDisposable, tabActionRunner, editorLabel));
return tabContainer; return tabContainer;
} }
......
...@@ -109,7 +109,7 @@ export abstract class TitleControl extends Themable { ...@@ -109,7 +109,7 @@ export abstract class TitleControl extends Themable {
this.registerListeners(); this.registerListeners();
} }
protected registerListeners(): void { private registerListeners(): void {
// Update actions toolbar when extension register that may contribute them // Update actions toolbar when extension register that may contribute them
this._register(this.extensionService.onDidRegisterExtensions(() => this.updateEditorActionsToolbar())); this._register(this.extensionService.onDidRegisterExtensions(() => this.updateEditorActionsToolbar()));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册