Skip to content

Commit 37732e9

Browse files
committed
Strict null check titlebarPart
1 parent f521072 commit 37732e9

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/tsconfig.strictNullChecks.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
"./vs/workbench/browser/parts/statusbar/statusbar.ts",
148148
"./vs/workbench/browser/parts/statusbar/statusbarPart.ts",
149149
"./vs/workbench/browser/parts/titlebar/menubarControl.ts",
150+
"./vs/workbench/browser/parts/titlebar/titlebarPart.ts",
150151
"./vs/workbench/browser/parts/views/customView.ts",
151152
"./vs/workbench/browser/parts/views/panelViewlet.ts",
152153
"./vs/workbench/browser/parts/views/views.ts",

src/vs/base/common/labels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ interface ISegment {
283283
* @param value string to which templating is applied
284284
* @param values the values of the templates to use
285285
*/
286-
export function template(template: string, values: { [key: string]: string | ISeparator } = Object.create(null)): string {
286+
export function template(template: string, values: { [key: string]: string | ISeparator | null } = Object.create(null)): string {
287287
const segments: ISegment[] = [];
288288

289289
let inVariable = false;

src/vs/workbench/browser/parts/titlebar/titlebarPart.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export class TitlebarPart extends Part implements ITitleService, ISerializableVi
180180
}
181181

182182
private updateRepresentedFilename(): void {
183-
const file = toResource(this.editorService.activeEditor, { supportSideBySide: true, filter: 'file' });
183+
const file = toResource(this.editorService.activeEditor || null, { supportSideBySide: true, filter: 'file' });
184184
const path = file ? file.fsPath : '';
185185

186186
// Apply to window
@@ -283,7 +283,7 @@ export class TitlebarPart extends Part implements ITitleService, ISerializableVi
283283
// Compute folder resource
284284
// Single Root Workspace: always the root single workspace in this case
285285
// Otherwise: root folder of the currently active file if any
286-
const folder = this.contextService.getWorkbenchState() === WorkbenchState.FOLDER ? workspace.folders[0] : this.contextService.getWorkspaceFolder(toResource(editor, { supportSideBySide: true }));
286+
const folder = this.contextService.getWorkbenchState() === WorkbenchState.FOLDER ? workspace.folders[0] : this.contextService.getWorkspaceFolder(toResource(editor || null, { supportSideBySide: true })!);
287287

288288
// Variables
289289
const activeEditorShort = editor ? editor.getTitle(Verbosity.SHORT) : '';
@@ -473,7 +473,7 @@ export class TitlebarPart extends Part implements ITitleService, ISerializableVi
473473

474474
const titleBackground = this.getColor(this.isInactive ? TITLE_BAR_INACTIVE_BACKGROUND : TITLE_BAR_ACTIVE_BACKGROUND);
475475
this.element.style.backgroundColor = titleBackground;
476-
if (Color.fromHex(titleBackground).isLighter()) {
476+
if (titleBackground && Color.fromHex(titleBackground).isLighter()) {
477477
addClass(this.element, 'light');
478478
} else {
479479
removeClass(this.element, 'light');
@@ -582,7 +582,7 @@ export class TitlebarPart extends Part implements ITitleService, ISerializableVi
582582
runAtThisOrScheduleAtNextAnimationFrame(() => this.adjustTitleMarginToCenter());
583583

584584
if (this.menubarPart) {
585-
const menubarDimension = new Dimension(undefined, dimension.height);
585+
const menubarDimension = new Dimension(0, dimension.height);
586586
this.menubarPart.layout(menubarDimension);
587587
}
588588
}
@@ -597,7 +597,7 @@ export class TitlebarPart extends Part implements ITitleService, ISerializableVi
597597
return super.layout(dim1);
598598
}
599599

600-
const dimensions = new Dimension(dim1, dim2);
600+
const dimensions = new Dimension(dim1, dim2!);
601601
this.updateLayout(dimensions);
602602

603603
super.layout(dimensions);

0 commit comments

Comments
 (0)