@codingame/monaco-vscode-multi-diff-editor-service-override 2.2.1 → 3.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/multiDiffEditor.contribution.js +3 -5
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.js +22 -0
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput.js +22 -19
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/scmMultiDiffSourceResolver.js +1 -0
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/utils.js +0 -57
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": "3.0.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,7 +18,7 @@
|
|
|
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@3.0.0",
|
|
22
22
|
"vscode-marked": "npm:marked@=3.0.2"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.contribution.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/confi
|
|
|
4
4
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
5
5
|
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
6
6
|
import { EditorPaneDescriptor } from 'vscode/vscode/vs/workbench/browser/editor';
|
|
7
|
-
import {
|
|
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
10
|
import { MultiDiffEditorResolverContribution, MultiDiffEditorInput, MultiDiffEditorSerializer } from './multiDiffEditorInput.js';
|
|
@@ -24,8 +24,7 @@ registerAction2(ExpandAllAction);
|
|
|
24
24
|
},
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
(
|
|
28
|
-
.registerWorkbenchContribution(MultiDiffEditorResolverContribution, 1 );
|
|
27
|
+
registerWorkbenchContribution2(MultiDiffEditorResolverContribution.ID, MultiDiffEditorResolverContribution, 1 );
|
|
29
28
|
( Registry.as(EditorExtensions.EditorPane))
|
|
30
29
|
.registerEditorPane(EditorPaneDescriptor.create(MultiDiffEditor, MultiDiffEditor.ID, ( localizeWithPath(
|
|
31
30
|
'vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.contribution',
|
|
@@ -35,5 +34,4 @@ registerAction2(ExpandAllAction);
|
|
|
35
34
|
( Registry.as(EditorExtensions.EditorFactory))
|
|
36
35
|
.registerEditorSerializer(MultiDiffEditorInput.ID, MultiDiffEditorSerializer);
|
|
37
36
|
registerAction2(OpenScmGroupAction);
|
|
38
|
-
(
|
|
39
|
-
.registerWorkbenchContribution(ScmMultiDiffSourceResolverContribution, 1 );
|
|
37
|
+
registerWorkbenchContribution2(ScmMultiDiffSourceResolverContribution.ID, ScmMultiDiffSourceResolverContribution, 1 );
|
|
@@ -10,6 +10,7 @@ import { AbstractEditorWithViewState } from 'vscode/vscode/vs/workbench/browser/
|
|
|
10
10
|
import { MultiDiffEditorInput } from './multiDiffEditorInput.js';
|
|
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
|
+
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
13
14
|
|
|
14
15
|
var MultiDiffEditor_1;
|
|
15
16
|
let MultiDiffEditor = class MultiDiffEditor extends AbstractEditorWithViewState {
|
|
@@ -36,6 +37,20 @@ let MultiDiffEditor = class MultiDiffEditor extends AbstractEditorWithViewState
|
|
|
36
37
|
if (viewState) {
|
|
37
38
|
this._multiDiffEditorWidget.setViewState(viewState);
|
|
38
39
|
}
|
|
40
|
+
this._applyOptions(options);
|
|
41
|
+
}
|
|
42
|
+
setOptions(options) {
|
|
43
|
+
this._applyOptions(options);
|
|
44
|
+
}
|
|
45
|
+
_applyOptions(options) {
|
|
46
|
+
const viewState = options?.viewState;
|
|
47
|
+
if (!viewState || !viewState.revealData) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this._multiDiffEditorWidget?.reveal(viewState.revealData.resource, {
|
|
51
|
+
range: viewState.revealData.range ? Range.lift(viewState.revealData.range) : undefined,
|
|
52
|
+
highlight: true
|
|
53
|
+
});
|
|
39
54
|
}
|
|
40
55
|
async clearInput() {
|
|
41
56
|
await super.clearInput();
|
|
@@ -47,6 +62,13 @@ let MultiDiffEditor = class MultiDiffEditor extends AbstractEditorWithViewState
|
|
|
47
62
|
getControl() {
|
|
48
63
|
return this._multiDiffEditorWidget.getActiveControl();
|
|
49
64
|
}
|
|
65
|
+
focus() {
|
|
66
|
+
super.focus();
|
|
67
|
+
this._multiDiffEditorWidget?.getActiveControl()?.focus();
|
|
68
|
+
}
|
|
69
|
+
hasFocus() {
|
|
70
|
+
return this._multiDiffEditorWidget?.getActiveControl()?.hasTextFocus() || super.hasFocus();
|
|
71
|
+
}
|
|
50
72
|
computeEditorViewState(resource) {
|
|
51
73
|
return this._multiDiffEditorWidget.getViewState();
|
|
52
74
|
}
|
|
@@ -19,9 +19,9 @@ import { DEFAULT_EDITOR_ASSOCIATION } from 'vscode/vscode/vs/workbench/common/ed
|
|
|
19
19
|
import { EditorInput } from 'vscode/vscode/vs/workbench/common/editor/editorInput';
|
|
20
20
|
import { MultiDiffEditorIcon } from './icons.contribution.js';
|
|
21
21
|
import { MultiDiffEditorItem, ConstResolvedMultiDiffSource, IMultiDiffSourceResolverService } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService';
|
|
22
|
-
import { ObservableLazyStatefulPromise } from './utils.js';
|
|
23
22
|
import { RegisteredEditorPriority, IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
|
|
24
23
|
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
24
|
+
import { ObservableLazyPromise } from 'vscode/vscode/vs/base/common/observableInternal/promise';
|
|
25
25
|
import { derived } from 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
26
26
|
import { autorun } from 'vscode/vscode/vs/base/common/observableInternal/autorun';
|
|
27
27
|
|
|
@@ -35,10 +35,10 @@ let MultiDiffEditorInput = class MultiDiffEditorInput extends EditorInput {
|
|
|
35
35
|
const multiDiffSource = input.multiDiffSource ?? ( URI.parse(`multi-diff-editor:${( ( new Date()).getMilliseconds().toString()) + ( Math.random().toString())}`));
|
|
36
36
|
return instantiationService.createInstance(MultiDiffEditorInput_1, multiDiffSource, input.label, input.resources?.map(resource => {
|
|
37
37
|
return ( new MultiDiffEditorItem(resource.original.resource, resource.modified.resource));
|
|
38
|
-
}));
|
|
38
|
+
}), input.isTransient ?? false);
|
|
39
39
|
}
|
|
40
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))));
|
|
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
42
|
}
|
|
43
43
|
static { this.ID = 'workbench.input.multiDiffEditor'; }
|
|
44
44
|
get resource() { return this.multiDiffSource; }
|
|
@@ -47,11 +47,12 @@ let MultiDiffEditorInput = class MultiDiffEditorInput extends EditorInput {
|
|
|
47
47
|
getName() { return this._name; }
|
|
48
48
|
get editorId() { return DEFAULT_EDITOR_ASSOCIATION.id; }
|
|
49
49
|
getIcon() { return MultiDiffEditorIcon; }
|
|
50
|
-
constructor(multiDiffSource, label, initialResources, _textModelService, _textResourceConfigurationService, _instantiationService, _multiDiffSourceResolverService, _textFileService) {
|
|
50
|
+
constructor(multiDiffSource, label, initialResources, isTransient = false, _textModelService, _textResourceConfigurationService, _instantiationService, _multiDiffSourceResolverService, _textFileService) {
|
|
51
51
|
super();
|
|
52
52
|
this.multiDiffSource = multiDiffSource;
|
|
53
53
|
this.label = label;
|
|
54
54
|
this.initialResources = initialResources;
|
|
55
|
+
this.isTransient = isTransient;
|
|
55
56
|
this._textModelService = _textModelService;
|
|
56
57
|
this._textResourceConfigurationService = _textResourceConfigurationService;
|
|
57
58
|
this._instantiationService = _instantiationService;
|
|
@@ -66,7 +67,7 @@ let MultiDiffEditorInput = class MultiDiffEditorInput extends EditorInput {
|
|
|
66
67
|
await raceTimeout(vm.waitForDiffs(), 1000);
|
|
67
68
|
return vm;
|
|
68
69
|
}));
|
|
69
|
-
this._resolvedSource = ( new
|
|
70
|
+
this._resolvedSource = ( new ObservableLazyPromise(async () => {
|
|
70
71
|
const source = this.initialResources
|
|
71
72
|
? ( new ConstResolvedMultiDiffSource(this.initialResources))
|
|
72
73
|
: await this._multiDiffSourceResolverService.resolve(this.multiDiffSource);
|
|
@@ -75,7 +76,7 @@ let MultiDiffEditorInput = class MultiDiffEditorInput extends EditorInput {
|
|
|
75
76
|
resources: source ? observableFromEvent(source.onDidChange, () => source.resources) : constObservable([]),
|
|
76
77
|
};
|
|
77
78
|
}));
|
|
78
|
-
this._resources = derived(this, reader => this._resolvedSource.
|
|
79
|
+
this._resources = derived(this, reader => this._resolvedSource.cachedPromiseResult.read(reader)?.data?.resources.read(reader));
|
|
79
80
|
this._isDirtyObservables = mapObservableArrayCached(this, ( this._resources.map(r => r || [])), res => {
|
|
80
81
|
const isModifiedDirty = res.modified ? isUriDirty(this._textFileService, res.modified) : constObservable(false);
|
|
81
82
|
const isOriginalDirty = res.original ? isUriDirty(this._textFileService, res.original) : constObservable(false);
|
|
@@ -99,12 +100,10 @@ let MultiDiffEditorInput = class MultiDiffEditorInput extends EditorInput {
|
|
|
99
100
|
'name',
|
|
100
101
|
"Multi Diff Editor"
|
|
101
102
|
));
|
|
102
|
-
this._name = label + ( localizeWithPath(
|
|
103
|
-
'
|
|
104
|
-
'files'
|
|
105
|
-
|
|
106
|
-
resources?.length ?? 0
|
|
107
|
-
));
|
|
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));
|
|
108
107
|
this._onDidChangeLabel.fire();
|
|
109
108
|
}));
|
|
110
109
|
}
|
|
@@ -134,7 +133,7 @@ let MultiDiffEditorInput = class MultiDiffEditorInput extends EditorInput {
|
|
|
134
133
|
return this._viewModel.getPromise();
|
|
135
134
|
}
|
|
136
135
|
async _createModel() {
|
|
137
|
-
const source = await this._resolvedSource.
|
|
136
|
+
const source = await this._resolvedSource.getPromise();
|
|
138
137
|
const textResourceConfigurationService = this._textResourceConfigurationService;
|
|
139
138
|
const garbage = ( new DisposableStore());
|
|
140
139
|
const documentsWithPromises = mapObservableArrayCached(undefined, source.resources, async (r, store) => {
|
|
@@ -232,11 +231,11 @@ let MultiDiffEditorInput = class MultiDiffEditorInput extends EditorInput {
|
|
|
232
231
|
}
|
|
233
232
|
};
|
|
234
233
|
MultiDiffEditorInput = MultiDiffEditorInput_1 = ( __decorate([
|
|
235
|
-
( __param(
|
|
236
|
-
( __param(
|
|
237
|
-
( __param(
|
|
238
|
-
( __param(
|
|
239
|
-
( __param(
|
|
234
|
+
( __param(4, ITextModelService)),
|
|
235
|
+
( __param(5, ITextResourceConfigurationService)),
|
|
236
|
+
( __param(6, IInstantiationService)),
|
|
237
|
+
( __param(7, IMultiDiffSourceResolverService)),
|
|
238
|
+
( __param(8, ITextFileService))
|
|
240
239
|
], MultiDiffEditorInput));
|
|
241
240
|
function isUriDirty(textFileService, uri) {
|
|
242
241
|
return observableFromEvent(Event.filter(textFileService.files.onDidChangeDirty, e => ( e.resource.toString()) === ( uri.toString())), () => textFileService.isDirty(uri));
|
|
@@ -260,6 +259,7 @@ function computeOptions(configuration) {
|
|
|
260
259
|
return editorConfiguration;
|
|
261
260
|
}
|
|
262
261
|
let MultiDiffEditorResolverContribution = class MultiDiffEditorResolverContribution extends Disposable {
|
|
262
|
+
static { this.ID = 'workbench.contrib.multiDiffEditorResolver'; }
|
|
263
263
|
constructor(editorResolverService, instantiationService) {
|
|
264
264
|
super();
|
|
265
265
|
this._register(editorResolverService.registerEditor(`*`, {
|
|
@@ -282,9 +282,12 @@ MultiDiffEditorResolverContribution = ( __decorate([
|
|
|
282
282
|
], MultiDiffEditorResolverContribution));
|
|
283
283
|
class MultiDiffEditorSerializer {
|
|
284
284
|
canSerialize(editor) {
|
|
285
|
-
return editor instanceof MultiDiffEditorInput;
|
|
285
|
+
return editor instanceof MultiDiffEditorInput && !editor.isTransient;
|
|
286
286
|
}
|
|
287
287
|
serialize(editor) {
|
|
288
|
+
if (!this.canSerialize(editor)) {
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
288
291
|
return JSON.stringify(editor.serialize());
|
|
289
292
|
}
|
|
290
293
|
deserialize(instantiationService, serializedEditor) {
|
package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/scmMultiDiffSourceResolver.js
CHANGED
|
@@ -97,6 +97,7 @@ function promiseFromEventState(event, checkState) {
|
|
|
97
97
|
}));
|
|
98
98
|
}
|
|
99
99
|
let ScmMultiDiffSourceResolverContribution = class ScmMultiDiffSourceResolverContribution extends Disposable {
|
|
100
|
+
static { this.ID = 'workbench.contrib.scmMultiDiffSourceResolver'; }
|
|
100
101
|
constructor(instantiationService, multiDiffSourceResolverService) {
|
|
101
102
|
super();
|
|
102
103
|
this._register(multiDiffSourceResolverService.registerResolver(instantiationService.createInstance(ScmMultiDiffSourceResolver)));
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { derived } from 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
2
|
-
import { observableValue } from 'vscode/vscode/vs/base/common/observableInternal/base';
|
|
3
|
-
|
|
4
|
-
class ObservableLazy {
|
|
5
|
-
get cachedValue() { return this._value; }
|
|
6
|
-
constructor(_computeValue) {
|
|
7
|
-
this._computeValue = _computeValue;
|
|
8
|
-
this._value = observableValue(this, undefined);
|
|
9
|
-
}
|
|
10
|
-
getValue() {
|
|
11
|
-
let v = this._value.get();
|
|
12
|
-
if (!v) {
|
|
13
|
-
v = this._computeValue();
|
|
14
|
-
this._value.set(v, undefined);
|
|
15
|
-
}
|
|
16
|
-
return v;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
class ObservablePromise {
|
|
20
|
-
constructor(promise) {
|
|
21
|
-
this._value = observableValue(this, undefined);
|
|
22
|
-
this.value = this._value;
|
|
23
|
-
this.promise = promise.then(value => {
|
|
24
|
-
this._value.set(( new PromiseResult(value, undefined)), undefined);
|
|
25
|
-
return value;
|
|
26
|
-
}, error => {
|
|
27
|
-
this._value.set(( new PromiseResult(undefined, error)), undefined);
|
|
28
|
-
throw error;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
class PromiseResult {
|
|
33
|
-
constructor(
|
|
34
|
-
value,
|
|
35
|
-
error) {
|
|
36
|
-
this.value = value;
|
|
37
|
-
this.error = error;
|
|
38
|
-
}
|
|
39
|
-
getValue() {
|
|
40
|
-
if (this.error) {
|
|
41
|
-
throw this.error;
|
|
42
|
-
}
|
|
43
|
-
return this.value;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
class ObservableLazyStatefulPromise {
|
|
47
|
-
constructor(_computeValue) {
|
|
48
|
-
this._computeValue = _computeValue;
|
|
49
|
-
this._lazyValue = ( new ObservableLazy(() => ( new ObservablePromise(this._computeValue()))));
|
|
50
|
-
this.cachedValue = derived(this, reader => this._lazyValue.cachedValue.read(reader)?.value.read(reader));
|
|
51
|
-
}
|
|
52
|
-
getValue() {
|
|
53
|
-
return this._lazyValue.getValue().promise;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export { ObservableLazy, ObservableLazyStatefulPromise, ObservablePromise, PromiseResult };
|