@@ -30,6 +30,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
3030import { Parts , IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService' ;
3131import { registerSingleton } from 'vs/platform/instantiation/common/extensions' ;
3232import { MementoObject } from 'vs/workbench/common/memento' ;
33+ import { assertIsDefined } from 'vs/base/common/types' ;
3334
3435interface IEditorPartUIState {
3536 serializedGrid : ISerializedGrid ;
@@ -49,13 +50,13 @@ class GridWidgetView<T extends IView> implements IView {
4950 private _onDidChange = new Relay < { width : number ; height : number ; } | undefined > ( ) ;
5051 readonly onDidChange : Event < { width : number ; height : number ; } | undefined > = this . _onDidChange . event ;
5152
52- private _gridWidget : Grid < T > ;
53+ private _gridWidget : Grid < T > | undefined ;
5354
54- get gridWidget ( ) : Grid < T > {
55+ get gridWidget ( ) : Grid < T > | undefined {
5556 return this . _gridWidget ;
5657 }
5758
58- set gridWidget ( grid : Grid < T > ) {
59+ set gridWidget ( grid : Grid < T > | undefined ) {
5960 this . element . innerHTML = '' ;
6061
6162 if ( grid ) {
@@ -123,17 +124,18 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
123124
124125 private _partOptions : IEditorPartOptions ;
125126
126- private _activeGroup : IEditorGroupView ;
127127 private groupViews : Map < GroupIdentifier , IEditorGroupView > = new Map < GroupIdentifier , IEditorGroupView > ( ) ;
128128 private mostRecentActiveGroups : GroupIdentifier [ ] = [ ] ;
129129
130- private container : HTMLElement ;
131- private centeredLayoutWidget : CenteredViewLayout ;
132- private gridWidget : SerializableGrid < IEditorGroupView > ;
130+ private container : HTMLElement | undefined ;
131+
132+ private centeredLayoutWidget ! : CenteredViewLayout ;
133+
134+ private gridWidget ! : SerializableGrid < IEditorGroupView > ;
133135 private gridWidgetView : GridWidgetView < IEditorGroupView > ;
134136
135137 private _whenRestored : Promise < void > ;
136- private whenRestoredResolve : ( ) => void ;
138+ private whenRestoredResolve : ( ( ) => void ) | undefined ;
137139
138140 constructor (
139141 @IInstantiationService private readonly instantiationService : IInstantiationService ,
@@ -204,9 +206,10 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
204206
205207 //#region IEditorGroupsService
206208
207- private _contentDimension : Dimension ;
209+ private _contentDimension ! : Dimension ;
208210 get contentDimension ( ) : Dimension { return this . _contentDimension ; }
209211
212+ private _activeGroup ! : IEditorGroupView ;
210213 get activeGroup ( ) : IEditorGroupView {
211214 return this . _activeGroup ;
212215 }
@@ -463,7 +466,11 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
463466 }
464467 }
465468
466- private shouldRestoreFocus ( target : Element ) : boolean {
469+ private shouldRestoreFocus ( target : Element | undefined ) : boolean {
470+ if ( ! target ) {
471+ return false ;
472+ }
473+
467474 const activeElement = document . activeElement ;
468475
469476 if ( activeElement === document . body ) {
@@ -796,7 +803,8 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
796803 }
797804
798805 updateStyles ( ) : void {
799- this . container . style . backgroundColor = this . getColor ( editorBackground ) || '' ;
806+ const container = assertIsDefined ( this . container ) ;
807+ container . style . backgroundColor = this . getColor ( editorBackground ) || '' ;
800808
801809 const separatorBorderStyle = { separatorBorder : this . gridSeparatorBorder , background : this . theme . getColor ( EDITOR_PANE_BACKGROUND ) || Color . transparent } ;
802810 this . gridWidget . style ( separatorBorderStyle ) ;
@@ -850,7 +858,11 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
850858 }
851859
852860 // Signal restored
853- Promise . all ( this . groups . map ( group => group . whenRestored ) ) . finally ( ( ) => this . whenRestoredResolve ( ) ) ;
861+ Promise . all ( this . groups . map ( group => group . whenRestored ) ) . finally ( ( ) => {
862+ if ( this . whenRestoredResolve ) {
863+ this . whenRestoredResolve ( ) ;
864+ }
865+ } ) ;
854866
855867 // Update container
856868 this . updateContainer ( ) ;
@@ -950,7 +962,8 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
950962 }
951963
952964 private updateContainer ( ) : void {
953- toggleClass ( this . container , 'empty' , this . isEmpty ) ;
965+ const container = assertIsDefined ( this . container ) ;
966+ toggleClass ( container , 'empty' , this . isEmpty ) ;
954967 }
955968
956969 private notifyGroupIndexChange ( ) : void {
0 commit comments