-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
130 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorViewModel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Disposable } from 'vs/base/common/lifecycle'; | ||
import { derivedWithStore, observableFromEvent, observableValue } from 'vs/base/common/observable'; | ||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditor/diffEditorWidget'; | ||
import { IDocumentDiffItem, IMultiDiffEditorModel, LazyPromise } from 'vs/editor/browser/widget/multiDiffEditorWidget/model'; | ||
import { IDiffEditorViewModel } from 'vs/editor/common/editorCommon'; | ||
|
||
export class MultiDiffEditorViewModel extends Disposable { | ||
private readonly _documents = observableFromEvent(this._model.onDidChange, /** @description MultiDiffEditorViewModel.documents */() => this._model.documents); | ||
|
||
public readonly items = derivedWithStore<readonly DocumentDiffItemViewModel[]>(this, | ||
(reader, store) => this._documents.read(reader).map(d => store.add(new DocumentDiffItemViewModel(d, this._diffEditorViewModelFactory))) | ||
).recomputeInitiallyAndOnChange(this._store); | ||
|
||
public readonly activeDiffItem = observableValue<DocumentDiffItemViewModel | undefined>(this, undefined); | ||
|
||
constructor( | ||
private readonly _model: IMultiDiffEditorModel, | ||
private readonly _diffEditorViewModelFactory: DiffEditorWidget | ||
) { | ||
super(); | ||
} | ||
} | ||
|
||
export class DocumentDiffItemViewModel extends Disposable { | ||
public readonly diffEditorViewModel: IDiffEditorViewModel; | ||
|
||
constructor( | ||
public readonly entry: LazyPromise<IDocumentDiffItem>, | ||
diffEditorViewModelFactory: DiffEditorWidget | ||
) { | ||
super(); | ||
|
||
this.diffEditorViewModel = this._register(diffEditorViewModelFactory.createViewModel({ | ||
original: entry.value!.original!, | ||
modified: entry.value!.modified!, | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters