diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 3c0eff3056e12b4fa4c2dccfbed1d28165046fed..a9c95b17047be5bbd306970462dc74da9ec18e06 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -527,6 +527,7 @@ "./vs/workbench/browser/parts/editor/baseEditor.ts", "./vs/workbench/browser/parts/editor/binaryEditor.ts", "./vs/workbench/browser/parts/editor/editor.ts", + "./vs/workbench/browser/parts/editor/editorControl.ts", "./vs/workbench/browser/parts/editor/editorWidgets.ts", "./vs/workbench/browser/parts/editor/rangeDecorations.ts", "./vs/workbench/browser/parts/editor/resourceViewer.ts", diff --git a/src/vs/workbench/browser/parts/editor/baseEditor.ts b/src/vs/workbench/browser/parts/editor/baseEditor.ts index 5dff202482566f72ac007f3ab5d49ce6a107fdbf..0e3ad345309b7fb9061bb301dd307b7617a8ed5d 100644 --- a/src/vs/workbench/browser/parts/editor/baseEditor.ts +++ b/src/vs/workbench/browser/parts/editor/baseEditor.ts @@ -77,7 +77,7 @@ export abstract class BaseEditor extends Panel implements IEditor { * The provided cancellation token should be used to test if the operation * was cancelled. */ - setInput(input: EditorInput, options: EditorOptions, token: CancellationToken): Promise { + setInput(input: EditorInput, options: EditorOptions | null, token: CancellationToken): Promise { this._input = input; this._options = options; @@ -100,7 +100,7 @@ export abstract class BaseEditor extends Panel implements IEditor { * Sets the given options to the editor. Clients should apply the options * to the current input. */ - setOptions(options: EditorOptions): void { + setOptions(options: EditorOptions | null): void { this._options = options; } diff --git a/src/vs/workbench/browser/parts/editor/editorControl.ts b/src/vs/workbench/browser/parts/editor/editorControl.ts index a557a7d82c469c900896d85722653eb7f0d85dc4..0d6945988f4282d456e475e4b086ee4567562197 100644 --- a/src/vs/workbench/browser/parts/editor/editorControl.ts +++ b/src/vs/workbench/browser/parts/editor/editorControl.ts @@ -30,10 +30,10 @@ export class EditorControl extends Disposable { private _onDidFocus: Emitter = this._register(new Emitter()); get onDidFocus(): Event { return this._onDidFocus.event; } - private _onDidSizeConstraintsChange = this._register(new Emitter<{ width: number; height: number; }>()); - get onDidSizeConstraintsChange(): Event<{ width: number; height: number; }> { return this._onDidSizeConstraintsChange.event; } + private _onDidSizeConstraintsChange = this._register(new Emitter<{ width: number; height: number; } | undefined>()); + get onDidSizeConstraintsChange(): Event<{ width: number; height: number; } | undefined> { return this._onDidSizeConstraintsChange.event; } - private _activeControl: BaseEditor; + private _activeControl: BaseEditor | null; private controls: BaseEditor[] = []; private activeControlDisposeables: IDisposable[] = []; @@ -52,7 +52,7 @@ export class EditorControl extends Disposable { this.editorOperation = this._register(new LongRunningOperation(progressService)); } - get activeControl(): BaseEditor { + get activeControl() { return this._activeControl; } @@ -60,10 +60,13 @@ export class EditorControl extends Disposable { // Editor control const descriptor = Registry.as(EditorExtensions.Editors).getEditor(editor); + if (!descriptor) { + throw new Error('No editor descriptor found'); + } const control = this.doShowEditorControl(descriptor); // Set input - return this.doSetInput(control, editor, options).then((editorChanged => (({ control, editorChanged } as IOpenEditorResult)))); + return this.doSetInput(control, editor, options || null).then((editorChanged => (({ control, editorChanged } as IOpenEditorResult)))); } private doShowEditorControl(descriptor: IEditorDescriptor): BaseEditor { @@ -129,7 +132,7 @@ export class EditorControl extends Disposable { return control; } - private doSetActiveControl(control: BaseEditor) { + private doSetActiveControl(control: BaseEditor | null) { this._activeControl = control; // Clear out previous active control listeners @@ -145,7 +148,7 @@ export class EditorControl extends Disposable { this._onDidSizeConstraintsChange.fire(undefined); } - private doSetInput(control: BaseEditor, editor: EditorInput, options: EditorOptions): Promise { + private doSetInput(control: BaseEditor, editor: EditorInput, options: EditorOptions | null): Promise { // If the input did not change, return early and only apply the options // unless the options instruct us to force open it even if it is the same