From 7c73dbe133156b6a6f01f55bef28f7fc060d48da Mon Sep 17 00:00:00 2001 From: Dennis Huebner Date: Fri, 9 Feb 2024 15:25:14 +0100 Subject: [PATCH] Applied re-view suggestions --- packages/core/src/browser/shell/tab-bar-decorator.ts | 11 +++++------ packages/core/src/browser/shell/tab-bars.ts | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/core/src/browser/shell/tab-bar-decorator.ts b/packages/core/src/browser/shell/tab-bar-decorator.ts index a19b71a7b260a..7b9d6a9756e9a 100644 --- a/packages/core/src/browser/shell/tab-bar-decorator.ts +++ b/packages/core/src/browser/shell/tab-bar-decorator.ts @@ -75,22 +75,21 @@ export class TabBarDecoratorService implements FrontendApplicationContribution { */ getDecorations(title: Title): WidgetDecoration.Data[] { const decorators = this.contributions.getContributions(); - let all: WidgetDecoration.Data[] = []; + const decorations: WidgetDecoration.Data[] = []; for (const decorator of decorators) { - const decorations = decorator.decorate(title); - all = all.concat(decorations); + decorations.push(...decorator.decorate(title)); } if (Navigatable.is(title.owner)) { const resourceUri = title.owner.getResourceUri(); if (resourceUri) { const serviceDecorations = this.decorationsService.getDecoration(resourceUri, false); - all.push(...serviceDecorations.map(d => this.toDecorator(d))); + decorations.push(...serviceDecorations.map(d => this.fromDecoration(d))); } } - return all; + return decorations; } - protected toDecorator(decoration: Decoration): WidgetDecoration.Data { + protected fromDecoration(decoration: Decoration): WidgetDecoration.Data { const colorVariable = decoration.colorId && this.colors.toCssVariableName(decoration.colorId); return { tailDecorations: [ diff --git a/packages/core/src/browser/shell/tab-bars.ts b/packages/core/src/browser/shell/tab-bars.ts index 1a858707165ec..e2d58ed9d61ee 100644 --- a/packages/core/src/browser/shell/tab-bars.ts +++ b/packages/core/src/browser/shell/tab-bars.ts @@ -17,7 +17,7 @@ import PerfectScrollbar from 'perfect-scrollbar'; import { TabBar, Title, Widget } from '@phosphor/widgets'; import { VirtualElement, h, VirtualDOM, ElementInlineStyle } from '@phosphor/virtualdom'; -import { Disposable, DisposableCollection, MenuPath, notEmpty, SelectionService, CommandService, nls } from '../../common'; +import { Disposable, DisposableCollection, MenuPath, notEmpty, SelectionService, CommandService, nls, ArrayUtils } from '../../common'; import { ContextMenuRenderer } from '../context-menu-renderer'; import { Signal, Slot } from '@phosphor/signaling'; import { Message, MessageLoop } from '@phosphor/messaging'; @@ -294,8 +294,8 @@ export class TabBarRenderer extends TabBar.Renderer { if (!this.corePreferences?.get('workbench.editor.decorations.badges')) { return []; } - const tailDecorations = this.getDecorationData(renderData.title, 'tailDecorations') - .filter(acc => acc !== undefined).reduce((acc, current) => acc!.concat(current!), []); + const tailDecorations = ArrayUtils.coalesce(this.getDecorationData(renderData.title, 'tailDecorations')) + .reduce((acc, current) => acc.concat(current), []); if (tailDecorations === undefined || tailDecorations.length === 0) { return []; }