@codingame/monaco-vscode-multi-diff-editor-service-override 37.2.0 → 37.3.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 +2 -2
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/actions.d.ts +0 -28
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/actions.js +0 -274
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorLayoutDebug.d.ts +0 -24
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorLayoutDebug.js +0 -128
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-multi-diff-editor-service-override",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - multi-diff-editor service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "37.
|
|
18
|
+
"@codingame/monaco-vscode-api": "37.3.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.contribution.js
CHANGED
|
@@ -8,7 +8,7 @@ import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monac
|
|
|
8
8
|
import { EditorExtensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
|
|
9
9
|
import { MultiDiffEditor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor';
|
|
10
10
|
import { MultiDiffEditorResolverContribution, MultiDiffEditorInput, MultiDiffEditorSerializer } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput';
|
|
11
|
-
import { GoToFileAction, GoToNextChangeAction, GoToPreviousChangeAction, CollapseAllAction, ExpandAllAction, OpenMultiDiffEditorLayoutDebugAction } from '
|
|
11
|
+
import { GoToFileAction, GoToNextChangeAction, GoToPreviousChangeAction, CollapseAllAction, ExpandAllAction, OpenMultiDiffEditorLayoutDebugAction } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/multiDiffEditor/browser/actions';
|
|
12
12
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
13
13
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
14
14
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
@@ -27,7 +27,7 @@ registerWorkbenchContribution2(
|
|
|
27
27
|
WorkbenchPhase.BlockStartup
|
|
28
28
|
);
|
|
29
29
|
( Registry.as(EditorExtensions.EditorPane)).registerEditorPane(
|
|
30
|
-
EditorPaneDescriptor.create(MultiDiffEditor, MultiDiffEditor.ID, ( localize(
|
|
30
|
+
EditorPaneDescriptor.create(MultiDiffEditor, MultiDiffEditor.ID, ( localize(16471, "Multi Diff Editor"))),
|
|
31
31
|
[( new SyncDescriptor(MultiDiffEditorInput))]
|
|
32
32
|
);
|
|
33
33
|
( Registry.as(EditorExtensions.EditorFactory)).registerEditorSerializer(MultiDiffEditorInput.ID, MultiDiffEditorSerializer);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Action2 } from "@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions";
|
|
2
|
-
import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
-
export declare class GoToFileAction extends Action2 {
|
|
4
|
-
constructor();
|
|
5
|
-
run(accessor: ServicesAccessor, ...args: unknown[]): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export declare class OpenMultiDiffEditorLayoutDebugAction extends Action2 {
|
|
8
|
-
static readonly ID = "multiDiffEditor.openLayoutDebug";
|
|
9
|
-
static readonly TITLE: import("@codingame/monaco-vscode-api/vscode/vs/nls").ILocalizedString;
|
|
10
|
-
constructor();
|
|
11
|
-
run(accessor: ServicesAccessor): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export declare class GoToNextChangeAction extends Action2 {
|
|
14
|
-
constructor();
|
|
15
|
-
run(accessor: ServicesAccessor): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export declare class GoToPreviousChangeAction extends Action2 {
|
|
18
|
-
constructor();
|
|
19
|
-
run(accessor: ServicesAccessor): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
export declare class CollapseAllAction extends Action2 {
|
|
22
|
-
constructor();
|
|
23
|
-
run(accessor: ServicesAccessor, ...args: unknown[]): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
export declare class ExpandAllAction extends Action2 {
|
|
26
|
-
constructor();
|
|
27
|
-
run(accessor: ServicesAccessor, ...args: unknown[]): Promise<void>;
|
|
28
|
-
}
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
3
|
-
import { KeyMod, KeyCode } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
|
|
4
|
-
import { Categories } from '@codingame/monaco-vscode-api/vscode/vs/platform/action/common/actionCommonCategories';
|
|
5
|
-
import { EditorContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/editorContextKeys';
|
|
6
|
-
import { ILanguageService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language.service';
|
|
7
|
-
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
|
|
8
|
-
import { localize, localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
9
|
-
import { MenuRegistry, MenuId, Action2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
10
|
-
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
11
|
-
import { TextEditorSelectionRevealType } from '@codingame/monaco-vscode-api/vscode/vs/platform/editor/common/editor';
|
|
12
|
-
import { KeybindingWeight } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybindingsRegistry';
|
|
13
|
-
import { IListService } from '@codingame/monaco-vscode-api/vscode/vs/platform/list/browser/listService.service';
|
|
14
|
-
import { resolveCommandsContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/browser/parts/editor/editorCommandsContext';
|
|
15
|
-
import { MultiDiffEditor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor';
|
|
16
|
-
import { MultiDiffEditorInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput';
|
|
17
|
-
import { IEditorGroupsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
|
|
18
|
-
import { AUX_WINDOW_GROUP, SIDE_GROUP } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService';
|
|
19
|
-
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
20
|
-
import { ActiveEditorContext, IsSessionsWindowContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contextkeys';
|
|
21
|
-
import { isMultiDiffEditorLayoutDebugStateProvider, createMultiDiffEditorLayoutDebugModel } from './multiDiffEditorLayoutDebug.js';
|
|
22
|
-
import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
23
|
-
|
|
24
|
-
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
|
|
25
|
-
submenu: MenuId.DiffEditorViewSubmenu,
|
|
26
|
-
title: ( localize(14324, "Diff View")),
|
|
27
|
-
group: "1_diff",
|
|
28
|
-
order: 10,
|
|
29
|
-
when: ( ContextKeyExpr.and(( ActiveEditorContext.isEqualTo(MultiDiffEditor.ID)), ( IsSessionsWindowContext.toNegated())))
|
|
30
|
-
});
|
|
31
|
-
class GoToFileAction extends Action2 {
|
|
32
|
-
constructor() {
|
|
33
|
-
super({
|
|
34
|
-
id: "multiDiffEditor.goToFile",
|
|
35
|
-
title: ( localize2(14325, "Open File")),
|
|
36
|
-
icon: Codicon.goToFile,
|
|
37
|
-
precondition: ( ActiveEditorContext.isEqualTo(MultiDiffEditor.ID)),
|
|
38
|
-
menu: {
|
|
39
|
-
when: ( ActiveEditorContext.isEqualTo(MultiDiffEditor.ID)),
|
|
40
|
-
id: MenuId.MultiDiffEditorFileToolbar,
|
|
41
|
-
order: 22,
|
|
42
|
-
group: "navigation"
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
async run(accessor, ...args) {
|
|
47
|
-
const uri = args[0];
|
|
48
|
-
const editorService = accessor.get(IEditorService);
|
|
49
|
-
const activeEditorPane = editorService.activeEditorPane;
|
|
50
|
-
let selections = undefined;
|
|
51
|
-
if (!(activeEditorPane instanceof MultiDiffEditor)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const editor = activeEditorPane.tryGetCodeEditor(uri);
|
|
55
|
-
if (editor) {
|
|
56
|
-
selections = editor.editor.getSelections() ?? undefined;
|
|
57
|
-
}
|
|
58
|
-
let targetUri = uri;
|
|
59
|
-
const item = activeEditorPane.findDocumentDiffItem(uri);
|
|
60
|
-
if (item && item.goToFileUri) {
|
|
61
|
-
targetUri = item.goToFileUri;
|
|
62
|
-
}
|
|
63
|
-
await editorService.openEditor({
|
|
64
|
-
label: item?.goToFileEditorTitle,
|
|
65
|
-
resource: targetUri,
|
|
66
|
-
options: {
|
|
67
|
-
selection: selections?.[0],
|
|
68
|
-
selectionRevealType: TextEditorSelectionRevealType.CenterIfOutsideViewport
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
class OpenMultiDiffEditorLayoutDebugAction extends Action2 {
|
|
74
|
-
static {
|
|
75
|
-
this.ID = "multiDiffEditor.openLayoutDebug";
|
|
76
|
-
}
|
|
77
|
-
static {
|
|
78
|
-
this.TITLE = ( localize2(14326, "Open Multi Diff Editor Layout Debug State"));
|
|
79
|
-
}
|
|
80
|
-
constructor() {
|
|
81
|
-
super({
|
|
82
|
-
id: OpenMultiDiffEditorLayoutDebugAction.ID,
|
|
83
|
-
title: OpenMultiDiffEditorLayoutDebugAction.TITLE,
|
|
84
|
-
category: Categories.Developer,
|
|
85
|
-
precondition: ( ContextKeyExpr.or(( ActiveEditorContext.isEqualTo(MultiDiffEditor.ID)), EditorContextKeys.inMultiDiffEditor)),
|
|
86
|
-
f1: true
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
async run(accessor) {
|
|
90
|
-
const editorService = accessor.get(IEditorService);
|
|
91
|
-
const environmentService = accessor.get(IWorkbenchEnvironmentService);
|
|
92
|
-
const activeEditorPane = editorService.activeEditorPane;
|
|
93
|
-
if (!isMultiDiffEditorLayoutDebugStateProvider(activeEditorPane)) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const model = createMultiDiffEditorLayoutDebugModel(
|
|
97
|
-
activeEditorPane.getLayoutDebugState(),
|
|
98
|
-
accessor.get(IModelService),
|
|
99
|
-
accessor.get(ILanguageService)
|
|
100
|
-
);
|
|
101
|
-
try {
|
|
102
|
-
const editor = await editorService.openEditor({
|
|
103
|
-
resource: model.uri,
|
|
104
|
-
options: {
|
|
105
|
-
pinned: true
|
|
106
|
-
}
|
|
107
|
-
}, environmentService.isSessionsWindow ? AUX_WINDOW_GROUP : SIDE_GROUP);
|
|
108
|
-
if (!editor) {
|
|
109
|
-
model.dispose();
|
|
110
|
-
}
|
|
111
|
-
} catch (error) {
|
|
112
|
-
model.dispose();
|
|
113
|
-
throw error;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
class GoToNextChangeAction extends Action2 {
|
|
118
|
-
constructor() {
|
|
119
|
-
super({
|
|
120
|
-
id: "multiDiffEditor.goToNextChange",
|
|
121
|
-
title: ( localize2(14327, "Go to Next Change")),
|
|
122
|
-
icon: Codicon.arrowDown,
|
|
123
|
-
precondition: ( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)),
|
|
124
|
-
menu: ( [MenuId.EditorTitle, MenuId.CompactWindowEditorTitle].map(id => ({
|
|
125
|
-
id,
|
|
126
|
-
when: ( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)),
|
|
127
|
-
group: "navigation",
|
|
128
|
-
order: 2
|
|
129
|
-
}))),
|
|
130
|
-
keybinding: {
|
|
131
|
-
primary: KeyMod.Alt | KeyCode.F5,
|
|
132
|
-
weight: KeybindingWeight.EditorContrib,
|
|
133
|
-
when: ( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID))
|
|
134
|
-
},
|
|
135
|
-
f1: true
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
async run(accessor) {
|
|
139
|
-
const editorService = accessor.get(IEditorService);
|
|
140
|
-
const activeEditorPane = editorService.activeEditorPane;
|
|
141
|
-
if (!(activeEditorPane instanceof MultiDiffEditor)) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
activeEditorPane.goToNextChange();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
class GoToPreviousChangeAction extends Action2 {
|
|
148
|
-
constructor() {
|
|
149
|
-
super({
|
|
150
|
-
id: "multiDiffEditor.goToPreviousChange",
|
|
151
|
-
title: ( localize2(14328, "Go to Previous Change")),
|
|
152
|
-
icon: Codicon.arrowUp,
|
|
153
|
-
precondition: ( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)),
|
|
154
|
-
menu: ( [MenuId.EditorTitle, MenuId.CompactWindowEditorTitle].map(id => ({
|
|
155
|
-
id,
|
|
156
|
-
when: ( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)),
|
|
157
|
-
group: "navigation",
|
|
158
|
-
order: 1
|
|
159
|
-
}))),
|
|
160
|
-
keybinding: {
|
|
161
|
-
primary: KeyMod.Alt | KeyMod.Shift | KeyCode.F5,
|
|
162
|
-
weight: KeybindingWeight.EditorContrib,
|
|
163
|
-
when: ( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID))
|
|
164
|
-
},
|
|
165
|
-
f1: true
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
async run(accessor) {
|
|
169
|
-
const editorService = accessor.get(IEditorService);
|
|
170
|
-
const activeEditorPane = editorService.activeEditorPane;
|
|
171
|
-
if (!(activeEditorPane instanceof MultiDiffEditor)) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
activeEditorPane.goToPreviousChange();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
class CollapseAllAction extends Action2 {
|
|
178
|
-
constructor() {
|
|
179
|
-
super({
|
|
180
|
-
id: "multiDiffEditor.collapseAll",
|
|
181
|
-
title: ( localize2(14329, "Collapse All Diffs")),
|
|
182
|
-
icon: Codicon.collapseAll,
|
|
183
|
-
precondition: ( ContextKeyExpr.and(( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)), ContextKeyExpr.not("multiDiffEditorAllCollapsed"))),
|
|
184
|
-
menu: [
|
|
185
|
-
{
|
|
186
|
-
id: MenuId.EditorTitle,
|
|
187
|
-
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)), ContextKeyExpr.not("multiDiffEditorAllCollapsed"), ( IsSessionsWindowContext.toNegated()))),
|
|
188
|
-
group: "navigation",
|
|
189
|
-
order: 100
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
id: MenuId.CompactWindowEditorTitle,
|
|
193
|
-
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)), ContextKeyExpr.not("multiDiffEditorAllCollapsed"))),
|
|
194
|
-
group: "navigation",
|
|
195
|
-
order: 100
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
id: MenuId.EditorTitle,
|
|
199
|
-
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)), ContextKeyExpr.not("multiDiffEditorAllCollapsed"), IsSessionsWindowContext)),
|
|
200
|
-
group: "4_collapse",
|
|
201
|
-
order: 10
|
|
202
|
-
}
|
|
203
|
-
],
|
|
204
|
-
f1: true
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
async run(accessor, ...args) {
|
|
208
|
-
const resolvedContext = resolveCommandsContext(
|
|
209
|
-
args,
|
|
210
|
-
accessor.get(IEditorService),
|
|
211
|
-
accessor.get(IEditorGroupsService),
|
|
212
|
-
accessor.get(IListService)
|
|
213
|
-
);
|
|
214
|
-
const groupContext = resolvedContext.groupedEditors[0];
|
|
215
|
-
if (!groupContext) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
const editor = groupContext.editors[0];
|
|
219
|
-
if (editor instanceof MultiDiffEditorInput) {
|
|
220
|
-
const viewModel = await editor.getViewModel();
|
|
221
|
-
viewModel.collapseAll();
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
class ExpandAllAction extends Action2 {
|
|
226
|
-
constructor() {
|
|
227
|
-
super({
|
|
228
|
-
id: "multiDiffEditor.expandAll",
|
|
229
|
-
title: ( localize2(14330, "Expand All Diffs")),
|
|
230
|
-
icon: Codicon.expandAll,
|
|
231
|
-
precondition: ( ContextKeyExpr.and(( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)), ( ContextKeyExpr.has("multiDiffEditorAllCollapsed")))),
|
|
232
|
-
menu: [
|
|
233
|
-
{
|
|
234
|
-
id: MenuId.EditorTitle,
|
|
235
|
-
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)), ( ContextKeyExpr.has("multiDiffEditorAllCollapsed")), ( IsSessionsWindowContext.toNegated()))),
|
|
236
|
-
group: "navigation",
|
|
237
|
-
order: 100
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
id: MenuId.CompactWindowEditorTitle,
|
|
241
|
-
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)), ( ContextKeyExpr.has("multiDiffEditorAllCollapsed")))),
|
|
242
|
-
group: "navigation",
|
|
243
|
-
order: 100
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
id: MenuId.EditorTitle,
|
|
247
|
-
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals("activeEditor", MultiDiffEditor.ID)), ( ContextKeyExpr.has("multiDiffEditorAllCollapsed")), IsSessionsWindowContext)),
|
|
248
|
-
group: "4_collapse",
|
|
249
|
-
order: 10
|
|
250
|
-
}
|
|
251
|
-
],
|
|
252
|
-
f1: true
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
async run(accessor, ...args) {
|
|
256
|
-
const resolvedContext = resolveCommandsContext(
|
|
257
|
-
args,
|
|
258
|
-
accessor.get(IEditorService),
|
|
259
|
-
accessor.get(IEditorGroupsService),
|
|
260
|
-
accessor.get(IListService)
|
|
261
|
-
);
|
|
262
|
-
const groupContext = resolvedContext.groupedEditors[0];
|
|
263
|
-
if (!groupContext) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
const editor = groupContext.editors[0];
|
|
267
|
-
if (editor instanceof MultiDiffEditorInput) {
|
|
268
|
-
const viewModel = await editor.getViewModel();
|
|
269
|
-
viewModel.expandAll();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export { CollapseAllAction, ExpandAllAction, GoToFileAction, GoToNextChangeAction, GoToPreviousChangeAction, OpenMultiDiffEditorLayoutDebugAction };
|
package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorLayoutDebug.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { JSONPath } from "@codingame/monaco-vscode-api/vscode/vs/base/common/json";
|
|
2
|
-
import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
|
3
|
-
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
4
|
-
import { IModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service";
|
|
5
|
-
import { ILanguageService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language.service";
|
|
6
|
-
import { IMultiDiffEditorLayoutDebugState } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/multiDiffEditor/multiDiffEditorWidgetImpl";
|
|
7
|
-
type JsonValue = null | boolean | number | string | readonly JsonValue[] | object;
|
|
8
|
-
export type JsonPatchOperation = {
|
|
9
|
-
readonly op: "add" | "replace";
|
|
10
|
-
readonly path: string;
|
|
11
|
-
readonly value: JsonValue;
|
|
12
|
-
} | {
|
|
13
|
-
readonly op: "remove";
|
|
14
|
-
readonly path: string;
|
|
15
|
-
};
|
|
16
|
-
export type JsonPatch = readonly (JsonPatchOperation | JsonPatch)[];
|
|
17
|
-
export interface IMultiDiffEditorLayoutDebugStateProvider {
|
|
18
|
-
getLayoutDebugState(): IObservable<IMultiDiffEditorLayoutDebugState>;
|
|
19
|
-
}
|
|
20
|
-
export declare function isMultiDiffEditorLayoutDebugStateProvider(candidate: object | undefined): candidate is IMultiDiffEditorLayoutDebugStateProvider;
|
|
21
|
-
export declare function createMultiDiffEditorLayoutDebugModel(state: IObservable<IMultiDiffEditorLayoutDebugState>, modelService: IModelService, languageService: ILanguageService): ITextModel;
|
|
22
|
-
export declare function createJsonPatch(previous: JsonValue, next: JsonValue, path?: JSONPath): JsonPatch;
|
|
23
|
-
export declare function applyJsonPatchToText(text: string, patch: JsonPatch): string;
|
|
24
|
-
export {};
|
package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorLayoutDebug.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import '@codingame/monaco-vscode-api/vscode/vs/base/common/json';
|
|
3
|
-
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
-
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
5
|
-
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
6
|
-
import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
|
|
7
|
-
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
8
|
-
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
9
|
-
|
|
10
|
-
function isMultiDiffEditorLayoutDebugStateProvider(candidate) {
|
|
11
|
-
return !!candidate && "getLayoutDebugState" in candidate && typeof candidate.getLayoutDebugState === "function";
|
|
12
|
-
}
|
|
13
|
-
function createMultiDiffEditorLayoutDebugModel(state, modelService, languageService) {
|
|
14
|
-
let previousState = state.get();
|
|
15
|
-
const id = generateUuid();
|
|
16
|
-
const logModel = modelService.createModel(`${JSON.stringify({
|
|
17
|
-
timestamp: Date.now(),
|
|
18
|
-
set: previousState
|
|
19
|
-
})}\n`, languageService.createById("jsonl"), ( URI.from({
|
|
20
|
-
scheme: Schemas.inMemory,
|
|
21
|
-
path: `/multi-diff-editor-layout-${id}.jsonl`
|
|
22
|
-
})));
|
|
23
|
-
const store = ( new DisposableStore());
|
|
24
|
-
store.add(logModel.onWillDispose(() => store.dispose()));
|
|
25
|
-
store.add(autorun(reader => {
|
|
26
|
-
const nextState = state.read(reader);
|
|
27
|
-
const operations = createJsonPatch(previousState, nextState);
|
|
28
|
-
if (!logModel.isDisposed() && operations.length > 0) {
|
|
29
|
-
appendJsonLines(logModel, [{
|
|
30
|
-
timestamp: Date.now(),
|
|
31
|
-
patch: operations
|
|
32
|
-
}]);
|
|
33
|
-
}
|
|
34
|
-
previousState = nextState;
|
|
35
|
-
}));
|
|
36
|
-
return logModel;
|
|
37
|
-
}
|
|
38
|
-
function createJsonPatch(previous, next, path = []) {
|
|
39
|
-
if (Object.is(previous, next)) {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
if (Array.isArray(previous) && Array.isArray(next)) {
|
|
43
|
-
if (previous.length !== next.length) {
|
|
44
|
-
return [{
|
|
45
|
-
op: "replace",
|
|
46
|
-
path: toJsonPointer(path),
|
|
47
|
-
value: next
|
|
48
|
-
}];
|
|
49
|
-
}
|
|
50
|
-
const operations = [];
|
|
51
|
-
for (let index = 0; index < previous.length; index++) {
|
|
52
|
-
appendJsonPatchOperations(
|
|
53
|
-
operations,
|
|
54
|
-
createJsonPatch(previous[index], next[index], [...path, index])
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
return operations;
|
|
58
|
-
}
|
|
59
|
-
if (isJsonObject(previous) && isJsonObject(next)) {
|
|
60
|
-
const operations = [];
|
|
61
|
-
for (const key of ( Object.keys(previous))) {
|
|
62
|
-
if (previous[key] !== undefined && next[key] === undefined) {
|
|
63
|
-
operations.push({
|
|
64
|
-
op: "remove",
|
|
65
|
-
path: toJsonPointer([...path, key])
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
for (const [key, value] of Object.entries(next)) {
|
|
70
|
-
if (value === undefined) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
const previousValue = previous[key];
|
|
74
|
-
if (previousValue === undefined) {
|
|
75
|
-
operations.push({
|
|
76
|
-
op: "add",
|
|
77
|
-
path: toJsonPointer([...path, key]),
|
|
78
|
-
value
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
appendJsonPatchOperations(operations, createJsonPatch(previousValue, value, [...path, key]));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return operations;
|
|
85
|
-
}
|
|
86
|
-
return [{
|
|
87
|
-
op: "replace",
|
|
88
|
-
path: toJsonPointer(path),
|
|
89
|
-
value: next
|
|
90
|
-
}];
|
|
91
|
-
}
|
|
92
|
-
function appendJsonPatchOperations(target, patch) {
|
|
93
|
-
forEachJsonPatchOperation(patch, operation => target.push(operation));
|
|
94
|
-
}
|
|
95
|
-
function forEachJsonPatchOperation(patch, callback) {
|
|
96
|
-
for (const entry of patch) {
|
|
97
|
-
if (isJsonPatch(entry)) {
|
|
98
|
-
forEachJsonPatchOperation(entry, callback);
|
|
99
|
-
} else {
|
|
100
|
-
callback(entry);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function isJsonPatch(value) {
|
|
105
|
-
return Array.isArray(value);
|
|
106
|
-
}
|
|
107
|
-
function appendJsonLines(model, values) {
|
|
108
|
-
const end = model.getPositionAt(model.getValueLength());
|
|
109
|
-
model.applyEdits([{
|
|
110
|
-
range: {
|
|
111
|
-
startLineNumber: end.lineNumber,
|
|
112
|
-
startColumn: end.column,
|
|
113
|
-
endLineNumber: end.lineNumber,
|
|
114
|
-
endColumn: end.column
|
|
115
|
-
},
|
|
116
|
-
text: ( values.map(value => `${JSON.stringify(value)}\n`)).join("")
|
|
117
|
-
}]);
|
|
118
|
-
}
|
|
119
|
-
function isJsonObject(value) {
|
|
120
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
121
|
-
}
|
|
122
|
-
function toJsonPointer(path) {
|
|
123
|
-
return ( path.map(
|
|
124
|
-
segment => `/${String(segment).replaceAll("~", "~0").replaceAll("/", "~1")}`
|
|
125
|
-
)).join("");
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export { createJsonPatch, createMultiDiffEditorLayoutDebugModel, isMultiDiffEditorLayoutDebugStateProvider };
|