提交 0362fc49 编写于 作者: M Matt Bierner

Strict null check editorControl

上级 899fb82c
......@@ -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",
......
......@@ -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<void> {
setInput(input: EditorInput, options: EditorOptions | null, token: CancellationToken): Promise<void> {
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;
}
......
......@@ -30,10 +30,10 @@ export class EditorControl extends Disposable {
private _onDidFocus: Emitter<void> = this._register(new Emitter<void>());
get onDidFocus(): Event<void> { 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<IEditorRegistry>(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<boolean> {
private doSetInput(control: BaseEditor, editor: EditorInput, options: EditorOptions | null): Promise<boolean> {
// 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册