@codingame/monaco-vscode-multi-diff-editor-service-override 3.2.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/actions.js +1 -1
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.contribution.js +4 -1
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.js +11 -11
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/scmMultiDiffSourceResolver.js +4 -1
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/model.js +0 -16
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/icons.contribution.js +0 -11
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput.js +0 -305
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-multi-diff-editor-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@4.0.0"
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -5,7 +5,7 @@ import { Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/action
|
|
|
5
5
|
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
6
6
|
import { TextFileEditor } from 'vscode/vscode/vs/workbench/contrib/files/browser/editors/textFileEditor';
|
|
7
7
|
import { MultiDiffEditor } from './multiDiffEditor.js';
|
|
8
|
-
import { MultiDiffEditorInput } from '
|
|
8
|
+
import { MultiDiffEditorInput } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput';
|
|
9
9
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
10
10
|
|
|
11
11
|
class GoToFileAction extends Action2 {
|
package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.contribution.js
CHANGED
|
@@ -7,8 +7,11 @@ import { EditorPaneDescriptor } from 'vscode/vscode/vs/workbench/browser/editor'
|
|
|
7
7
|
import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
8
8
|
import { EditorExtensions } from 'vscode/vscode/vs/workbench/common/editor';
|
|
9
9
|
import { MultiDiffEditor } from './multiDiffEditor.js';
|
|
10
|
-
import { MultiDiffEditorResolverContribution, MultiDiffEditorInput, MultiDiffEditorSerializer } from '
|
|
10
|
+
import { MultiDiffEditorResolverContribution, MultiDiffEditorInput, MultiDiffEditorSerializer } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput';
|
|
11
11
|
import { GoToFileAction, CollapseAllAction, ExpandAllAction } from './actions.js';
|
|
12
|
+
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
13
|
+
import 'vscode/vscode/vs/base/common/event';
|
|
14
|
+
import 'vscode/vscode/vs/base/common/lifecycle';
|
|
12
15
|
import { OpenScmGroupAction, ScmMultiDiffSourceResolverContribution } from './scmMultiDiffSourceResolver.js';
|
|
13
16
|
|
|
14
17
|
registerAction2(GoToFileAction);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { MultiDiffEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/
|
|
2
|
+
import { MultiDiffEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/multiDiffEditor/multiDiffEditorWidget';
|
|
3
3
|
import { ITextResourceConfigurationService } from 'vscode/vscode/vs/editor/common/services/textResourceConfiguration';
|
|
4
4
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
5
5
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
@@ -7,7 +7,7 @@ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/te
|
|
|
7
7
|
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
8
8
|
import { ResourceLabel } from 'vscode/vscode/vs/workbench/browser/labels';
|
|
9
9
|
import { AbstractEditorWithViewState } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorWithViewState';
|
|
10
|
-
import { MultiDiffEditorInput } from '
|
|
10
|
+
import { MultiDiffEditorInput } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput';
|
|
11
11
|
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
12
12
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
13
13
|
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
@@ -19,8 +19,8 @@ let MultiDiffEditor = class MultiDiffEditor extends AbstractEditorWithViewState
|
|
|
19
19
|
get viewModel() {
|
|
20
20
|
return this._viewModel;
|
|
21
21
|
}
|
|
22
|
-
constructor(instantiationService, telemetryService, themeService, storageService, editorService, editorGroupService, textResourceConfigurationService) {
|
|
23
|
-
super(MultiDiffEditor_1.ID, 'multiDiffEditor', telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorService, editorGroupService);
|
|
22
|
+
constructor(group, instantiationService, telemetryService, themeService, storageService, editorService, editorGroupService, textResourceConfigurationService) {
|
|
23
|
+
super(MultiDiffEditor_1.ID, group, 'multiDiffEditor', telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorService, editorGroupService);
|
|
24
24
|
this._multiDiffEditorWidget = undefined;
|
|
25
25
|
}
|
|
26
26
|
createEditor(parent) {
|
|
@@ -83,13 +83,13 @@ let MultiDiffEditor = class MultiDiffEditor extends AbstractEditorWithViewState
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
MultiDiffEditor = MultiDiffEditor_1 = ( __decorate([
|
|
86
|
-
( __param(
|
|
87
|
-
( __param(
|
|
88
|
-
( __param(
|
|
89
|
-
( __param(
|
|
90
|
-
( __param(
|
|
91
|
-
( __param(
|
|
92
|
-
( __param(
|
|
86
|
+
( __param(1, IInstantiationService)),
|
|
87
|
+
( __param(2, ITelemetryService)),
|
|
88
|
+
( __param(3, IThemeService)),
|
|
89
|
+
( __param(4, IStorageService)),
|
|
90
|
+
( __param(5, IEditorService)),
|
|
91
|
+
( __param(6, IEditorGroupsService)),
|
|
92
|
+
( __param(7, ITextResourceConfigurationService))
|
|
93
93
|
], MultiDiffEditor));
|
|
94
94
|
let WorkbenchUIElementFactory = class WorkbenchUIElementFactory {
|
|
95
95
|
constructor(_instantiationService) {
|
package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/scmMultiDiffSourceResolver.js
CHANGED
|
@@ -2,6 +2,10 @@ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.e
|
|
|
2
2
|
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
3
3
|
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
4
4
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
6
|
+
import 'vscode/vscode/vs/base/common/observableInternal/autorun';
|
|
7
|
+
import { observableFromEvent } from 'vscode/vscode/vs/base/common/observableInternal/utils';
|
|
8
|
+
import 'vscode/vscode/vs/base/common/cancellation';
|
|
5
9
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
6
10
|
import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
7
11
|
import { Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
@@ -10,7 +14,6 @@ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/c
|
|
|
10
14
|
import { IMultiDiffSourceResolverService } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService';
|
|
11
15
|
import { ISCMService } from 'vscode/vscode/vs/workbench/contrib/scm/common/scm';
|
|
12
16
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
13
|
-
import { observableFromEvent } from 'vscode/vscode/vs/base/common/observableInternal/utils';
|
|
14
17
|
|
|
15
18
|
var ScmMultiDiffSourceResolver_1;
|
|
16
19
|
let ScmMultiDiffSourceResolver = class ScmMultiDiffSourceResolver {
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
2
|
-
|
|
3
|
-
class ConstLazyPromise {
|
|
4
|
-
constructor(_value) {
|
|
5
|
-
this._value = _value;
|
|
6
|
-
this.onHasValueDidChange = Event.None;
|
|
7
|
-
}
|
|
8
|
-
request() {
|
|
9
|
-
return Promise.resolve(this._value);
|
|
10
|
-
}
|
|
11
|
-
get value() {
|
|
12
|
-
return this._value;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { ConstLazyPromise };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
2
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
-
import { registerIcon } from 'vscode/vscode/vs/platform/theme/common/iconRegistry';
|
|
4
|
-
|
|
5
|
-
const MultiDiffEditorIcon = registerIcon('multi-diff-editor-label-icon', Codicon.diffMultiple, ( localizeWithPath(
|
|
6
|
-
'vs/workbench/contrib/multiDiffEditor/browser/icons.contribution',
|
|
7
|
-
'multiDiffEditorLabelIcon',
|
|
8
|
-
'Icon of the multi diff editor label.'
|
|
9
|
-
)));
|
|
10
|
-
|
|
11
|
-
export { MultiDiffEditorIcon };
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { LazyStatefulPromise, raceTimeout } from 'vscode/vscode/vs/base/common/async';
|
|
3
|
-
import { BugIndicatingError, onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
|
|
4
|
-
import { Event, Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
5
|
-
import { DisposableStore, toDisposable, Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
6
|
-
import { parse } from 'vscode/vscode/vs/base/common/marshalling';
|
|
7
|
-
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
8
|
-
import { deepClone } from 'vscode/vscode/vs/base/common/objects';
|
|
9
|
-
import { observableFromEvent, constObservable, mapObservableArrayCached } from 'vscode/vscode/vs/base/common/observableInternal/utils';
|
|
10
|
-
import { isDefined, isObject } from 'vscode/vscode/vs/base/common/types';
|
|
11
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
12
|
-
import { ConstLazyPromise } from '../../../../editor/browser/widget/multiDiffEditorWidget/model.js';
|
|
13
|
-
import { MultiDiffEditorViewModel } from 'vscode/vscode/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorViewModel';
|
|
14
|
-
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
15
|
-
import { ITextResourceConfigurationService } from 'vscode/vscode/vs/editor/common/services/textResourceConfiguration';
|
|
16
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
17
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
18
|
-
import { DEFAULT_EDITOR_ASSOCIATION } from 'vscode/vscode/vs/workbench/common/editor';
|
|
19
|
-
import { EditorInput } from 'vscode/vscode/vs/workbench/common/editor/editorInput';
|
|
20
|
-
import { MultiDiffEditorIcon } from './icons.contribution.js';
|
|
21
|
-
import { MultiDiffEditorItem, ConstResolvedMultiDiffSource, IMultiDiffSourceResolverService } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService';
|
|
22
|
-
import { RegisteredEditorPriority, IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
|
|
23
|
-
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
24
|
-
import { ObservableLazyPromise } from 'vscode/vscode/vs/base/common/observableInternal/promise';
|
|
25
|
-
import { derived } from 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
26
|
-
import { autorun } from 'vscode/vscode/vs/base/common/observableInternal/autorun';
|
|
27
|
-
|
|
28
|
-
var MultiDiffEditorInput_1;
|
|
29
|
-
let MultiDiffEditorInput = class MultiDiffEditorInput extends EditorInput {
|
|
30
|
-
static { MultiDiffEditorInput_1 = this; }
|
|
31
|
-
static fromResourceMultiDiffEditorInput(input, instantiationService) {
|
|
32
|
-
if (!input.multiDiffSource && !input.resources) {
|
|
33
|
-
throw new BugIndicatingError('MultiDiffEditorInput requires either multiDiffSource or resources');
|
|
34
|
-
}
|
|
35
|
-
const multiDiffSource = input.multiDiffSource ?? ( URI.parse(`multi-diff-editor:${( ( new Date()).getMilliseconds().toString()) + ( Math.random().toString())}`));
|
|
36
|
-
return instantiationService.createInstance(MultiDiffEditorInput_1, multiDiffSource, input.label, input.resources?.map(resource => {
|
|
37
|
-
return ( new MultiDiffEditorItem(resource.original.resource, resource.modified.resource));
|
|
38
|
-
}), input.isTransient ?? false);
|
|
39
|
-
}
|
|
40
|
-
static fromSerialized(data, instantiationService) {
|
|
41
|
-
return instantiationService.createInstance(MultiDiffEditorInput_1, ( URI.parse(data.multiDiffSourceUri)), data.label, data.resources?.map(resource => ( new MultiDiffEditorItem(resource.originalUri ? ( URI.parse(resource.originalUri)) : undefined, resource.modifiedUri ? ( URI.parse(resource.modifiedUri)) : undefined))), false);
|
|
42
|
-
}
|
|
43
|
-
static { this.ID = 'workbench.input.multiDiffEditor'; }
|
|
44
|
-
get resource() { return this.multiDiffSource; }
|
|
45
|
-
get capabilities() { return 2 ; }
|
|
46
|
-
get typeId() { return MultiDiffEditorInput_1.ID; }
|
|
47
|
-
getName() { return this._name; }
|
|
48
|
-
get editorId() { return DEFAULT_EDITOR_ASSOCIATION.id; }
|
|
49
|
-
getIcon() { return MultiDiffEditorIcon; }
|
|
50
|
-
constructor(multiDiffSource, label, initialResources, isTransient = false, _textModelService, _textResourceConfigurationService, _instantiationService, _multiDiffSourceResolverService, _textFileService) {
|
|
51
|
-
super();
|
|
52
|
-
this.multiDiffSource = multiDiffSource;
|
|
53
|
-
this.label = label;
|
|
54
|
-
this.initialResources = initialResources;
|
|
55
|
-
this.isTransient = isTransient;
|
|
56
|
-
this._textModelService = _textModelService;
|
|
57
|
-
this._textResourceConfigurationService = _textResourceConfigurationService;
|
|
58
|
-
this._instantiationService = _instantiationService;
|
|
59
|
-
this._multiDiffSourceResolverService = _multiDiffSourceResolverService;
|
|
60
|
-
this._textFileService = _textFileService;
|
|
61
|
-
this._name = '';
|
|
62
|
-
this._viewModel = ( new LazyStatefulPromise(async () => {
|
|
63
|
-
const model = await this._createModel();
|
|
64
|
-
this._register(model);
|
|
65
|
-
const vm = ( new MultiDiffEditorViewModel(model, this._instantiationService));
|
|
66
|
-
this._register(vm);
|
|
67
|
-
await raceTimeout(vm.waitForDiffs(), 1000);
|
|
68
|
-
return vm;
|
|
69
|
-
}));
|
|
70
|
-
this._resolvedSource = ( new ObservableLazyPromise(async () => {
|
|
71
|
-
const source = this.initialResources
|
|
72
|
-
? ( new ConstResolvedMultiDiffSource(this.initialResources))
|
|
73
|
-
: await this._multiDiffSourceResolverService.resolve(this.multiDiffSource);
|
|
74
|
-
return {
|
|
75
|
-
source,
|
|
76
|
-
resources: source ? observableFromEvent(source.onDidChange, () => source.resources) : constObservable([]),
|
|
77
|
-
};
|
|
78
|
-
}));
|
|
79
|
-
this._resources = derived(this, reader => this._resolvedSource.cachedPromiseResult.read(reader)?.data?.resources.read(reader));
|
|
80
|
-
this._isDirtyObservables = mapObservableArrayCached(this, ( this._resources.map(r => r || [])), res => {
|
|
81
|
-
const isModifiedDirty = res.modified ? isUriDirty(this._textFileService, res.modified) : constObservable(false);
|
|
82
|
-
const isOriginalDirty = res.original ? isUriDirty(this._textFileService, res.original) : constObservable(false);
|
|
83
|
-
return derived(reader => isModifiedDirty.read(reader) || isOriginalDirty.read(reader));
|
|
84
|
-
}, i => JSON.stringify([i.modified?.toString(), i.original?.toString()]));
|
|
85
|
-
this._isDirtyObservable = derived(this, reader => ( this._isDirtyObservables.read(reader).some(isDirty => isDirty.read(reader))))
|
|
86
|
-
.keepObserved(this._store);
|
|
87
|
-
this.onDidChangeDirty = Event.fromObservableLight(this._isDirtyObservable);
|
|
88
|
-
this.closeHandler = {
|
|
89
|
-
async confirm() {
|
|
90
|
-
return 1 ;
|
|
91
|
-
},
|
|
92
|
-
showConfirm() {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
this._register(autorun((reader) => {
|
|
97
|
-
const resources = this._resources.read(reader) ?? [];
|
|
98
|
-
const label = this.label ?? ( localizeWithPath(
|
|
99
|
-
'vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput',
|
|
100
|
-
'name',
|
|
101
|
-
"Multi Diff Editor"
|
|
102
|
-
));
|
|
103
|
-
this._name = label + ( localizeWithPath('vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput', {
|
|
104
|
-
key: 'files',
|
|
105
|
-
comment: ['the number of files being shown']
|
|
106
|
-
}, " ({0} files)", resources?.length ?? 0));
|
|
107
|
-
this._onDidChangeLabel.fire();
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
110
|
-
serialize() {
|
|
111
|
-
return {
|
|
112
|
-
label: this.label,
|
|
113
|
-
multiDiffSourceUri: ( this.multiDiffSource.toString()),
|
|
114
|
-
resources: this.initialResources?.map(resource => ({
|
|
115
|
-
originalUri: resource.original?.toString(),
|
|
116
|
-
modifiedUri: resource.modified?.toString(),
|
|
117
|
-
})),
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
setLanguageId(languageId, source) {
|
|
121
|
-
const activeDiffItem = this._viewModel.requireValue().activeDiffItem.get();
|
|
122
|
-
const value = activeDiffItem?.entry?.value;
|
|
123
|
-
if (!value) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const target = value.modified ?? value.original;
|
|
127
|
-
if (!target) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
target.setLanguage(languageId, source);
|
|
131
|
-
}
|
|
132
|
-
async getViewModel() {
|
|
133
|
-
return this._viewModel.getPromise();
|
|
134
|
-
}
|
|
135
|
-
async _createModel() {
|
|
136
|
-
const source = await this._resolvedSource.getPromise();
|
|
137
|
-
const textResourceConfigurationService = this._textResourceConfigurationService;
|
|
138
|
-
const garbage = ( new DisposableStore());
|
|
139
|
-
const documentsWithPromises = mapObservableArrayCached(undefined, source.resources, async (r, store) => {
|
|
140
|
-
let original;
|
|
141
|
-
let modified;
|
|
142
|
-
const store2 = ( new DisposableStore());
|
|
143
|
-
store.add(toDisposable(() => {
|
|
144
|
-
garbage.add(store2);
|
|
145
|
-
}));
|
|
146
|
-
try {
|
|
147
|
-
[original, modified] = await Promise.all([
|
|
148
|
-
r.original ? this._textModelService.createModelReference(r.original) : undefined,
|
|
149
|
-
r.modified ? this._textModelService.createModelReference(r.modified) : undefined,
|
|
150
|
-
]);
|
|
151
|
-
if (original) {
|
|
152
|
-
store.add(original);
|
|
153
|
-
}
|
|
154
|
-
if (modified) {
|
|
155
|
-
store.add(modified);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
catch (e) {
|
|
159
|
-
console.error(e);
|
|
160
|
-
onUnexpectedError(e);
|
|
161
|
-
return undefined;
|
|
162
|
-
}
|
|
163
|
-
const uri = (r.modified ?? r.original);
|
|
164
|
-
return ( new ConstLazyPromise({
|
|
165
|
-
original: original?.object.textEditorModel,
|
|
166
|
-
modified: modified?.object.textEditorModel,
|
|
167
|
-
get options() {
|
|
168
|
-
return {
|
|
169
|
-
...getReadonlyConfiguration(modified?.object.isReadonly() ?? true),
|
|
170
|
-
...computeOptions(textResourceConfigurationService.getValue(uri)),
|
|
171
|
-
};
|
|
172
|
-
},
|
|
173
|
-
onOptionsDidChange: h => this._textResourceConfigurationService.onDidChangeConfiguration(e => {
|
|
174
|
-
if (e.affectsConfiguration(uri, 'editor') || e.affectsConfiguration(uri, 'diffEditor')) {
|
|
175
|
-
h();
|
|
176
|
-
}
|
|
177
|
-
}),
|
|
178
|
-
}));
|
|
179
|
-
}, i => JSON.stringify([i.modified?.toString(), i.original?.toString()]));
|
|
180
|
-
let documents = [];
|
|
181
|
-
const documentChangeEmitter = ( new Emitter());
|
|
182
|
-
const p = Event.toPromise(documentChangeEmitter.event);
|
|
183
|
-
const a = autorun(async (reader) => {
|
|
184
|
-
const docsPromises = documentsWithPromises.read(reader);
|
|
185
|
-
const docs = await Promise.all(docsPromises);
|
|
186
|
-
documents = docs.filter(isDefined);
|
|
187
|
-
documentChangeEmitter.fire();
|
|
188
|
-
garbage.clear();
|
|
189
|
-
});
|
|
190
|
-
await p;
|
|
191
|
-
return {
|
|
192
|
-
dispose: () => {
|
|
193
|
-
a.dispose();
|
|
194
|
-
garbage.dispose();
|
|
195
|
-
},
|
|
196
|
-
onDidChange: documentChangeEmitter.event,
|
|
197
|
-
get documents() { return documents; },
|
|
198
|
-
contextKeys: source.source?.contextKeys,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
matches(otherInput) {
|
|
202
|
-
if (super.matches(otherInput)) {
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
if (otherInput instanceof MultiDiffEditorInput_1) {
|
|
206
|
-
return ( this.multiDiffSource.toString()) === ( otherInput.multiDiffSource.toString());
|
|
207
|
-
}
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
isDirty() { return this._isDirtyObservable.get(); }
|
|
211
|
-
async save(group, options) {
|
|
212
|
-
await this.doSaveOrRevert('save', group, options);
|
|
213
|
-
return this;
|
|
214
|
-
}
|
|
215
|
-
revert(group, options) {
|
|
216
|
-
return this.doSaveOrRevert('revert', group, options);
|
|
217
|
-
}
|
|
218
|
-
async doSaveOrRevert(mode, group, options) {
|
|
219
|
-
const items = this._viewModel.currentValue?.items.get();
|
|
220
|
-
if (items) {
|
|
221
|
-
await Promise.all(( items.map(async (item) => {
|
|
222
|
-
const model = item.diffEditorViewModel.model;
|
|
223
|
-
const handleOriginal = model.original.uri.scheme !== Schemas.untitled && this._textFileService.isDirty(model.original.uri);
|
|
224
|
-
await Promise.all([
|
|
225
|
-
handleOriginal ? mode === 'save' ? this._textFileService.save(model.original.uri, options) : this._textFileService.revert(model.original.uri, options) : Promise.resolve(),
|
|
226
|
-
mode === 'save' ? this._textFileService.save(model.modified.uri, options) : this._textFileService.revert(model.modified.uri, options),
|
|
227
|
-
]);
|
|
228
|
-
})));
|
|
229
|
-
}
|
|
230
|
-
return undefined;
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
MultiDiffEditorInput = MultiDiffEditorInput_1 = ( __decorate([
|
|
234
|
-
( __param(4, ITextModelService)),
|
|
235
|
-
( __param(5, ITextResourceConfigurationService)),
|
|
236
|
-
( __param(6, IInstantiationService)),
|
|
237
|
-
( __param(7, IMultiDiffSourceResolverService)),
|
|
238
|
-
( __param(8, ITextFileService))
|
|
239
|
-
], MultiDiffEditorInput));
|
|
240
|
-
function isUriDirty(textFileService, uri) {
|
|
241
|
-
return observableFromEvent(Event.filter(textFileService.files.onDidChangeDirty, e => ( e.resource.toString()) === ( uri.toString())), () => textFileService.isDirty(uri));
|
|
242
|
-
}
|
|
243
|
-
function getReadonlyConfiguration(isReadonly) {
|
|
244
|
-
return {
|
|
245
|
-
readOnly: !!isReadonly,
|
|
246
|
-
readOnlyMessage: typeof isReadonly !== 'boolean' ? isReadonly : undefined
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
function computeOptions(configuration) {
|
|
250
|
-
const editorConfiguration = deepClone(configuration.editor);
|
|
251
|
-
if (isObject(configuration.diffEditor)) {
|
|
252
|
-
const diffEditorConfiguration = deepClone(configuration.diffEditor);
|
|
253
|
-
diffEditorConfiguration.diffCodeLens = diffEditorConfiguration.codeLens;
|
|
254
|
-
delete diffEditorConfiguration.codeLens;
|
|
255
|
-
diffEditorConfiguration.diffWordWrap = diffEditorConfiguration.wordWrap;
|
|
256
|
-
delete diffEditorConfiguration.wordWrap;
|
|
257
|
-
Object.assign(editorConfiguration, diffEditorConfiguration);
|
|
258
|
-
}
|
|
259
|
-
return editorConfiguration;
|
|
260
|
-
}
|
|
261
|
-
let MultiDiffEditorResolverContribution = class MultiDiffEditorResolverContribution extends Disposable {
|
|
262
|
-
static { this.ID = 'workbench.contrib.multiDiffEditorResolver'; }
|
|
263
|
-
constructor(editorResolverService, instantiationService) {
|
|
264
|
-
super();
|
|
265
|
-
this._register(editorResolverService.registerEditor(`*`, {
|
|
266
|
-
id: DEFAULT_EDITOR_ASSOCIATION.id,
|
|
267
|
-
label: DEFAULT_EDITOR_ASSOCIATION.displayName,
|
|
268
|
-
detail: DEFAULT_EDITOR_ASSOCIATION.providerDisplayName,
|
|
269
|
-
priority: RegisteredEditorPriority.builtin
|
|
270
|
-
}, {}, {
|
|
271
|
-
createMultiDiffEditorInput: (diffListEditor) => {
|
|
272
|
-
return {
|
|
273
|
-
editor: MultiDiffEditorInput.fromResourceMultiDiffEditorInput(diffListEditor, instantiationService),
|
|
274
|
-
};
|
|
275
|
-
},
|
|
276
|
-
}));
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
MultiDiffEditorResolverContribution = ( __decorate([
|
|
280
|
-
( __param(0, IEditorResolverService)),
|
|
281
|
-
( __param(1, IInstantiationService))
|
|
282
|
-
], MultiDiffEditorResolverContribution));
|
|
283
|
-
class MultiDiffEditorSerializer {
|
|
284
|
-
canSerialize(editor) {
|
|
285
|
-
return editor instanceof MultiDiffEditorInput && !editor.isTransient;
|
|
286
|
-
}
|
|
287
|
-
serialize(editor) {
|
|
288
|
-
if (!this.canSerialize(editor)) {
|
|
289
|
-
return undefined;
|
|
290
|
-
}
|
|
291
|
-
return JSON.stringify(editor.serialize());
|
|
292
|
-
}
|
|
293
|
-
deserialize(instantiationService, serializedEditor) {
|
|
294
|
-
try {
|
|
295
|
-
const data = parse(serializedEditor);
|
|
296
|
-
return MultiDiffEditorInput.fromSerialized(data, instantiationService);
|
|
297
|
-
}
|
|
298
|
-
catch (err) {
|
|
299
|
-
onUnexpectedError(err);
|
|
300
|
-
return undefined;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
export { MultiDiffEditorInput, MultiDiffEditorResolverContribution, MultiDiffEditorSerializer };
|