提交 314564c5 编写于 作者: M Matt Bierner

Strict null check diffEditorModel

上级 d52d4bb0
......@@ -141,6 +141,7 @@
"./vs/workbench/common/editor.ts",
"./vs/workbench/common/editor/binaryEditorModel.ts",
"./vs/workbench/common/editor/dataUriEditorInput.ts",
"./vs/workbench/common/editor/diffEditorInput.ts",
"./vs/workbench/common/editor/diffEditorModel.ts",
"./vs/workbench/common/editor/editorGroup.ts",
"./vs/workbench/common/editor/resourceEditorInput.ts",
......@@ -251,6 +252,7 @@
"./vs/workbench/contrib/output/common/output.ts",
"./vs/workbench/contrib/output/common/outputLinkComputer.ts",
"./vs/workbench/contrib/output/common/outputLinkProvider.ts",
"./vs/workbench/contrib/output/electron-browser/outputServices.ts",
"./vs/workbench/contrib/output/node/outputAppender.ts",
"./vs/workbench/contrib/preferences/browser/settingsWidgets.ts",
"./vs/workbench/contrib/preferences/common/smartSnippetInserter.ts",
......
......@@ -11,33 +11,39 @@ import { IEditorModel } from 'vs/platform/editor/common/editor';
* and the modified version.
*/
export class DiffEditorModel extends EditorModel {
protected _originalModel: IEditorModel;
protected _modifiedModel: IEditorModel;
protected _originalModel: IEditorModel | null;
protected _modifiedModel: IEditorModel | null;
constructor(originalModel: IEditorModel, modifiedModel: IEditorModel) {
constructor(originalModel: IEditorModel | null, modifiedModel: IEditorModel | null) {
super();
this._originalModel = originalModel;
this._modifiedModel = modifiedModel;
}
get originalModel(): EditorModel {
get originalModel(): EditorModel | null {
if (!this._originalModel) {
return null;
}
return this._originalModel as EditorModel;
}
get modifiedModel(): EditorModel {
get modifiedModel(): EditorModel | null {
if (!this._modifiedModel) {
return null;
}
return this._modifiedModel as EditorModel;
}
load(): Promise<EditorModel> {
return Promise.all([
this._originalModel.load(),
this._modifiedModel.load()
this._originalModel ? this._originalModel.load() : Promise.resolve(undefined),
this._modifiedModel ? this._modifiedModel.load() : Promise.resolve(undefined),
]).then(() => this);
}
isResolved(): boolean {
return this.originalModel.isResolved() && this.modifiedModel.isResolved();
return !!this.originalModel && this.originalModel.isResolved() && !!this.modifiedModel && this.modifiedModel.isResolved();
}
dispose(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册