forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiffEditorModel.ts
More file actions
47 lines (36 loc) · 1.72 KB
/
diffEditorModel.ts
File metadata and controls
47 lines (36 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { EditorModel } from 'vs/workbench/common/editor/editorModel';
import { IEditorModel } from 'vs/platform/editor/common/editor';
/**
* The base editor model for the diff editor. It is made up of two editor models, the original version
* and the modified version.
*/
export class DiffEditorModel extends EditorModel {
protected readonly _originalModel: IEditorModel | undefined;
get originalModel(): IEditorModel | undefined { return this._originalModel; }
protected readonly _modifiedModel: IEditorModel | undefined;
get modifiedModel(): IEditorModel | undefined { return this._modifiedModel; }
constructor(originalModel: IEditorModel | undefined, modifiedModel: IEditorModel | undefined) {
super();
this._originalModel = originalModel;
this._modifiedModel = modifiedModel;
}
override async resolve(): Promise<void> {
await Promise.all([
this._originalModel?.resolve(),
this._modifiedModel?.resolve()
]);
}
override isResolved(): boolean {
return !!(this.originalModel?.isResolved() && this.modifiedModel?.isResolved());
}
override dispose(): void {
// Do not propagate the dispose() call to the two models inside. We never created the two models
// (original and modified) so we can not dispose them without sideeffects. Rather rely on the
// models getting disposed when their related inputs get disposed from the diffEditorInput.
super.dispose();
}
}