@codingame/monaco-vscode-api 33.0.3 → 33.0.4
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 +9 -9
- package/services.js +3 -3
- package/vscode/src/vs/platform/product/common/product.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.d.ts +0 -26
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +0 -746
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -300
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.d.ts +0 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -55
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.d.ts +0 -273
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1963
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.d.ts +0 -50
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -314
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.d.ts +0 -258
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -886
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.d.ts +0 -41
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -118
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.d.ts +0 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.js +0 -71
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.d.ts +0 -27
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -40
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.d.ts +0 -23
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.js +0 -313
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.d.ts +0 -51
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.js +0 -265
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.d.ts +0 -24
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.js +0 -185
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.d.ts +0 -28
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.js +0 -104
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.d.ts +0 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.js +0 -43
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.d.ts +0 -21
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.js +0 -41
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.d.ts +0 -25
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.js +0 -69
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css +0 -469
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.d.ts +0 -149
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -933
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.d.ts +0 -180
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -32
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.d.ts +0 -102
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -643
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.d.ts +0 -30
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -197
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.d.ts +0 -75
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.js +0 -539
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.js +0 -39
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.d.ts +0 -19
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.js +0 -90
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.d.ts +0 -26
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.js +0 -92
|
@@ -1,539 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Emitter } from '../../../../../base/common/event.js';
|
|
3
|
-
import { Disposable, DisposableStore, dispose } from '../../../../../base/common/lifecycle.js';
|
|
4
|
-
import { Schemas } from '../../../../../base/common/network.js';
|
|
5
|
-
import { MultiDiffEditorItem } from '../../../multiDiffEditor/browser/multiDiffSourceResolverService.js';
|
|
6
|
-
import { DiffElementPlaceholderViewModel, NotebookDocumentMetadataViewModel, SideBySideDiffElementViewModel, SingleSideDiffElementViewModel } from './diffElementViewModel.js';
|
|
7
|
-
import { NOTEBOOK_DIFF_ITEM_DIFF_STATE, NOTEBOOK_DIFF_ITEM_KIND } from './notebookDiffEditorBrowser.js';
|
|
8
|
-
import { CellUri } from '../../common/notebookCommon.js';
|
|
9
|
-
import { raceCancellation } from '../../../../../base/common/async.js';
|
|
10
|
-
import { computeDiff } from '../../common/notebookDiff.js';
|
|
11
|
-
|
|
12
|
-
class NotebookDiffViewModel extends Disposable {
|
|
13
|
-
get items() {
|
|
14
|
-
return this._items;
|
|
15
|
-
}
|
|
16
|
-
get value() {
|
|
17
|
-
return this.diffEditorItems.filter(item => item.type !== "placeholder").filter(item => {
|
|
18
|
-
if (this._includeUnchanged) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
if (item instanceof NotebookMultiDiffEditorCellItem) {
|
|
22
|
-
return item.type === "unchanged" && item.containerType === "unchanged" ? false : true;
|
|
23
|
-
}
|
|
24
|
-
if (item instanceof NotebookMultiDiffEditorMetadataItem) {
|
|
25
|
-
return item.type === "unchanged" && item.containerType === "unchanged" ? false : true;
|
|
26
|
-
}
|
|
27
|
-
if (item instanceof NotebookMultiDiffEditorOutputItem) {
|
|
28
|
-
return item.type === "unchanged" && item.containerType === "unchanged" ? false : true;
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
}).filter(
|
|
32
|
-
item => item instanceof NotebookMultiDiffEditorOutputItem ? !this.hideOutput : true
|
|
33
|
-
).filter(
|
|
34
|
-
item => item instanceof NotebookMultiDiffEditorMetadataItem ? !this.ignoreMetadata : true
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
get hasUnchangedCells() {
|
|
38
|
-
return this._hasUnchangedCells === true;
|
|
39
|
-
}
|
|
40
|
-
get includeUnchanged() {
|
|
41
|
-
return this._includeUnchanged === true;
|
|
42
|
-
}
|
|
43
|
-
set includeUnchanged(value) {
|
|
44
|
-
this._includeUnchanged = value;
|
|
45
|
-
this._onDidChange.fire();
|
|
46
|
-
}
|
|
47
|
-
constructor(
|
|
48
|
-
model,
|
|
49
|
-
notebookEditorWorkerService,
|
|
50
|
-
configurationService,
|
|
51
|
-
eventDispatcher,
|
|
52
|
-
notebookService,
|
|
53
|
-
diffEditorHeightCalculator,
|
|
54
|
-
fontInfo,
|
|
55
|
-
excludeUnchangedPlaceholder
|
|
56
|
-
) {
|
|
57
|
-
super();
|
|
58
|
-
this.model = model;
|
|
59
|
-
this.notebookEditorWorkerService = notebookEditorWorkerService;
|
|
60
|
-
this.configurationService = configurationService;
|
|
61
|
-
this.eventDispatcher = eventDispatcher;
|
|
62
|
-
this.notebookService = notebookService;
|
|
63
|
-
this.diffEditorHeightCalculator = diffEditorHeightCalculator;
|
|
64
|
-
this.fontInfo = fontInfo;
|
|
65
|
-
this.excludeUnchangedPlaceholder = excludeUnchangedPlaceholder;
|
|
66
|
-
this.placeholderAndRelatedCells = ( new Map());
|
|
67
|
-
this._items = [];
|
|
68
|
-
this._onDidChangeItems = this._register(( new Emitter()));
|
|
69
|
-
this.onDidChangeItems = this._onDidChangeItems.event;
|
|
70
|
-
this.disposables = this._register(( new DisposableStore()));
|
|
71
|
-
this._onDidChange = this._register(( new Emitter()));
|
|
72
|
-
this.diffEditorItems = [];
|
|
73
|
-
this.onDidChange = this._onDidChange.event;
|
|
74
|
-
this.originalCellViewModels = [];
|
|
75
|
-
this.hideOutput = this.model.modified.notebook.transientOptions.transientOutputs || this.configurationService.getValue("notebook.diff.ignoreOutputs");
|
|
76
|
-
this.ignoreMetadata = this.configurationService.getValue("notebook.diff.ignoreMetadata");
|
|
77
|
-
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
|
78
|
-
let triggerChange = false;
|
|
79
|
-
let metadataChanged = false;
|
|
80
|
-
if (e.affectsConfiguration("notebook.diff.ignoreMetadata")) {
|
|
81
|
-
const newValue = this.configurationService.getValue("notebook.diff.ignoreMetadata");
|
|
82
|
-
if (newValue !== undefined && this.ignoreMetadata !== newValue) {
|
|
83
|
-
this.ignoreMetadata = newValue;
|
|
84
|
-
triggerChange = true;
|
|
85
|
-
metadataChanged = true;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (e.affectsConfiguration("notebook.diff.ignoreOutputs")) {
|
|
89
|
-
const newValue = this.configurationService.getValue("notebook.diff.ignoreOutputs");
|
|
90
|
-
if (newValue !== undefined && this.hideOutput !== (newValue || this.model.modified.notebook.transientOptions.transientOutputs)) {
|
|
91
|
-
this.hideOutput = newValue || !!(this.model.modified.notebook.transientOptions.transientOutputs);
|
|
92
|
-
triggerChange = true;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (metadataChanged) {
|
|
96
|
-
this.toggleNotebookMetadata();
|
|
97
|
-
}
|
|
98
|
-
if (triggerChange) {
|
|
99
|
-
this._onDidChange.fire();
|
|
100
|
-
}
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
dispose() {
|
|
104
|
-
this.clear();
|
|
105
|
-
super.dispose();
|
|
106
|
-
}
|
|
107
|
-
clear() {
|
|
108
|
-
this.disposables.clear();
|
|
109
|
-
dispose(Array.from(( this.placeholderAndRelatedCells.keys())));
|
|
110
|
-
this.placeholderAndRelatedCells.clear();
|
|
111
|
-
dispose(this.originalCellViewModels);
|
|
112
|
-
this.originalCellViewModels = [];
|
|
113
|
-
dispose(this._items);
|
|
114
|
-
this._items.splice(0, this._items.length);
|
|
115
|
-
}
|
|
116
|
-
async computeDiff(token) {
|
|
117
|
-
const diffResult = await raceCancellation(
|
|
118
|
-
this.notebookEditorWorkerService.computeDiff(this.model.original.resource, this.model.modified.resource),
|
|
119
|
-
token
|
|
120
|
-
);
|
|
121
|
-
if (!diffResult || token.isCancellationRequested) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
prettyChanges(
|
|
125
|
-
this.model.original.notebook,
|
|
126
|
-
this.model.modified.notebook,
|
|
127
|
-
diffResult.cellsDiff
|
|
128
|
-
);
|
|
129
|
-
const {
|
|
130
|
-
cellDiffInfo,
|
|
131
|
-
firstChangeIndex
|
|
132
|
-
} = computeDiff(this.model.original.notebook, this.model.modified.notebook, diffResult);
|
|
133
|
-
if (isEqual(cellDiffInfo, this.originalCellViewModels, this.model)) {
|
|
134
|
-
return;
|
|
135
|
-
} else {
|
|
136
|
-
await raceCancellation(
|
|
137
|
-
this.updateViewModels(cellDiffInfo, diffResult.metadataChanged, firstChangeIndex),
|
|
138
|
-
token
|
|
139
|
-
);
|
|
140
|
-
if (token.isCancellationRequested) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
this.updateDiffEditorItems();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
toggleNotebookMetadata() {
|
|
147
|
-
if (!this.notebookMetadataViewModel) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (this.ignoreMetadata) {
|
|
151
|
-
if (this._items.length && this._items[0] === this.notebookMetadataViewModel) {
|
|
152
|
-
this._items.splice(0, 1);
|
|
153
|
-
this._onDidChangeItems.fire({
|
|
154
|
-
start: 0,
|
|
155
|
-
deleteCount: 1,
|
|
156
|
-
elements: []
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
} else {
|
|
160
|
-
if (!this._items.length || this._items[0] !== this.notebookMetadataViewModel) {
|
|
161
|
-
this._items.splice(0, 0, this.notebookMetadataViewModel);
|
|
162
|
-
this._onDidChangeItems.fire({
|
|
163
|
-
start: 0,
|
|
164
|
-
deleteCount: 0,
|
|
165
|
-
elements: [this.notebookMetadataViewModel]
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
updateDiffEditorItems() {
|
|
171
|
-
this.diffEditorItems = [];
|
|
172
|
-
const originalSourceUri = this.model.original.resource;
|
|
173
|
-
const modifiedSourceUri = this.model.modified.resource;
|
|
174
|
-
this._hasUnchangedCells = false;
|
|
175
|
-
this.items.forEach(item => {
|
|
176
|
-
switch (item.type) {
|
|
177
|
-
case "delete":
|
|
178
|
-
{
|
|
179
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorCellItem(item.original.uri, undefined, item.type, item.type)));
|
|
180
|
-
const originalMetadata = CellUri.generateCellPropertyUri(
|
|
181
|
-
originalSourceUri,
|
|
182
|
-
item.original.handle,
|
|
183
|
-
Schemas.vscodeNotebookCellMetadata
|
|
184
|
-
);
|
|
185
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorMetadataItem(originalMetadata, undefined, item.type, item.type)));
|
|
186
|
-
const originalOutput = CellUri.generateCellPropertyUri(originalSourceUri, item.original.handle, Schemas.vscodeNotebookCellOutput);
|
|
187
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorOutputItem(originalOutput, undefined, item.type, item.type)));
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
case "insert":
|
|
191
|
-
{
|
|
192
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorCellItem(undefined, item.modified.uri, item.type, item.type)));
|
|
193
|
-
const modifiedMetadata = CellUri.generateCellPropertyUri(
|
|
194
|
-
modifiedSourceUri,
|
|
195
|
-
item.modified.handle,
|
|
196
|
-
Schemas.vscodeNotebookCellMetadata
|
|
197
|
-
);
|
|
198
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorMetadataItem(undefined, modifiedMetadata, item.type, item.type)));
|
|
199
|
-
const modifiedOutput = CellUri.generateCellPropertyUri(modifiedSourceUri, item.modified.handle, Schemas.vscodeNotebookCellOutput);
|
|
200
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorOutputItem(undefined, modifiedOutput, item.type, item.type)));
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
case "modified":
|
|
204
|
-
{
|
|
205
|
-
const cellType = item.checkIfInputModified() ? item.type : "unchanged";
|
|
206
|
-
const containerChanged = (item.checkIfInputModified() || item.checkMetadataIfModified() || item.checkIfOutputsModified()) ? item.type : "unchanged";
|
|
207
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorCellItem(item.original.uri, item.modified.uri, cellType, containerChanged)));
|
|
208
|
-
const originalMetadata = CellUri.generateCellPropertyUri(
|
|
209
|
-
originalSourceUri,
|
|
210
|
-
item.original.handle,
|
|
211
|
-
Schemas.vscodeNotebookCellMetadata
|
|
212
|
-
);
|
|
213
|
-
const modifiedMetadata = CellUri.generateCellPropertyUri(
|
|
214
|
-
modifiedSourceUri,
|
|
215
|
-
item.modified.handle,
|
|
216
|
-
Schemas.vscodeNotebookCellMetadata
|
|
217
|
-
);
|
|
218
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorMetadataItem(
|
|
219
|
-
originalMetadata,
|
|
220
|
-
modifiedMetadata,
|
|
221
|
-
item.checkMetadataIfModified() ? item.type : "unchanged",
|
|
222
|
-
containerChanged
|
|
223
|
-
)));
|
|
224
|
-
const originalOutput = CellUri.generateCellPropertyUri(originalSourceUri, item.original.handle, Schemas.vscodeNotebookCellOutput);
|
|
225
|
-
const modifiedOutput = CellUri.generateCellPropertyUri(modifiedSourceUri, item.modified.handle, Schemas.vscodeNotebookCellOutput);
|
|
226
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorOutputItem(
|
|
227
|
-
originalOutput,
|
|
228
|
-
modifiedOutput,
|
|
229
|
-
item.checkIfOutputsModified() ? item.type : "unchanged",
|
|
230
|
-
containerChanged
|
|
231
|
-
)));
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
case "unchanged":
|
|
235
|
-
{
|
|
236
|
-
this._hasUnchangedCells = true;
|
|
237
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorCellItem(item.original.uri, item.modified.uri, item.type, item.type)));
|
|
238
|
-
const originalMetadata = CellUri.generateCellPropertyUri(
|
|
239
|
-
originalSourceUri,
|
|
240
|
-
item.original.handle,
|
|
241
|
-
Schemas.vscodeNotebookCellMetadata
|
|
242
|
-
);
|
|
243
|
-
const modifiedMetadata = CellUri.generateCellPropertyUri(
|
|
244
|
-
modifiedSourceUri,
|
|
245
|
-
item.modified.handle,
|
|
246
|
-
Schemas.vscodeNotebookCellMetadata
|
|
247
|
-
);
|
|
248
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorMetadataItem(originalMetadata, modifiedMetadata, item.type, item.type)));
|
|
249
|
-
const originalOutput = CellUri.generateCellPropertyUri(originalSourceUri, item.original.handle, Schemas.vscodeNotebookCellOutput);
|
|
250
|
-
const modifiedOutput = CellUri.generateCellPropertyUri(modifiedSourceUri, item.modified.handle, Schemas.vscodeNotebookCellOutput);
|
|
251
|
-
this.diffEditorItems.push(( new NotebookMultiDiffEditorOutputItem(originalOutput, modifiedOutput, item.type, item.type)));
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
this._onDidChange.fire();
|
|
257
|
-
}
|
|
258
|
-
async updateViewModels(cellDiffInfo, metadataChanged, firstChangeIndex) {
|
|
259
|
-
const cellViewModels = await this.createDiffViewModels(cellDiffInfo, metadataChanged);
|
|
260
|
-
const oldLength = this._items.length;
|
|
261
|
-
this.clear();
|
|
262
|
-
this._items.splice(0, oldLength);
|
|
263
|
-
let placeholder = undefined;
|
|
264
|
-
this.originalCellViewModels = cellViewModels;
|
|
265
|
-
cellViewModels.forEach((vm, index) => {
|
|
266
|
-
if (vm.type === "unchanged" && !this.excludeUnchangedPlaceholder) {
|
|
267
|
-
if (!placeholder) {
|
|
268
|
-
vm.displayIconToHideUnmodifiedCells = true;
|
|
269
|
-
placeholder = ( new DiffElementPlaceholderViewModel(vm.mainDocumentTextModel, vm.editorEventDispatcher, vm.initData));
|
|
270
|
-
this._items.push(placeholder);
|
|
271
|
-
const placeholderItem = placeholder;
|
|
272
|
-
this.disposables.add(placeholderItem.onUnfoldHiddenCells(() => {
|
|
273
|
-
const hiddenCellViewModels = this.placeholderAndRelatedCells.get(placeholderItem);
|
|
274
|
-
if (!Array.isArray(hiddenCellViewModels)) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
const start = this._items.indexOf(placeholderItem);
|
|
278
|
-
this._items.splice(start, 1, ...hiddenCellViewModels);
|
|
279
|
-
this._onDidChangeItems.fire({
|
|
280
|
-
start,
|
|
281
|
-
deleteCount: 1,
|
|
282
|
-
elements: hiddenCellViewModels
|
|
283
|
-
});
|
|
284
|
-
}));
|
|
285
|
-
this.disposables.add(vm.onHideUnchangedCells(() => {
|
|
286
|
-
const hiddenCellViewModels = this.placeholderAndRelatedCells.get(placeholderItem);
|
|
287
|
-
if (!Array.isArray(hiddenCellViewModels)) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
const start = this._items.indexOf(vm);
|
|
291
|
-
this._items.splice(start, hiddenCellViewModels.length, placeholderItem);
|
|
292
|
-
this._onDidChangeItems.fire({
|
|
293
|
-
start,
|
|
294
|
-
deleteCount: hiddenCellViewModels.length,
|
|
295
|
-
elements: [placeholderItem]
|
|
296
|
-
});
|
|
297
|
-
}));
|
|
298
|
-
}
|
|
299
|
-
const hiddenCellViewModels = this.placeholderAndRelatedCells.get(placeholder) || [];
|
|
300
|
-
hiddenCellViewModels.push(vm);
|
|
301
|
-
this.placeholderAndRelatedCells.set(placeholder, hiddenCellViewModels);
|
|
302
|
-
placeholder.hiddenCells.push(vm);
|
|
303
|
-
} else {
|
|
304
|
-
placeholder = undefined;
|
|
305
|
-
this._items.push(vm);
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
this._onDidChangeItems.fire({
|
|
309
|
-
start: 0,
|
|
310
|
-
deleteCount: oldLength,
|
|
311
|
-
elements: this._items,
|
|
312
|
-
firstChangeIndex
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
async createDiffViewModels(computedCellDiffs, metadataChanged) {
|
|
316
|
-
const originalModel = this.model.original.notebook;
|
|
317
|
-
const modifiedModel = this.model.modified.notebook;
|
|
318
|
-
const initData = {
|
|
319
|
-
metadataStatusHeight: this.configurationService.getValue("notebook.diff.ignoreMetadata") ? 0 : 25,
|
|
320
|
-
outputStatusHeight: this.configurationService.getValue("notebook.diff.ignoreOutputs") || !!(modifiedModel.transientOptions.transientOutputs) ? 0 : 25,
|
|
321
|
-
fontInfo: this.fontInfo
|
|
322
|
-
};
|
|
323
|
-
const viewModels = [];
|
|
324
|
-
this.notebookMetadataViewModel = this._register(( new NotebookDocumentMetadataViewModel(
|
|
325
|
-
this.model.original.notebook,
|
|
326
|
-
this.model.modified.notebook,
|
|
327
|
-
metadataChanged ? "modifiedMetadata" : "unchangedMetadata",
|
|
328
|
-
this.eventDispatcher,
|
|
329
|
-
initData,
|
|
330
|
-
this.notebookService,
|
|
331
|
-
this.diffEditorHeightCalculator
|
|
332
|
-
)));
|
|
333
|
-
if (!this.ignoreMetadata) {
|
|
334
|
-
if (metadataChanged) {
|
|
335
|
-
await this.notebookMetadataViewModel.computeHeights();
|
|
336
|
-
}
|
|
337
|
-
viewModels.push(this.notebookMetadataViewModel);
|
|
338
|
-
}
|
|
339
|
-
const cellViewModels = await Promise.all(( computedCellDiffs.map(async diff => {
|
|
340
|
-
switch (diff.type) {
|
|
341
|
-
case "delete":
|
|
342
|
-
{
|
|
343
|
-
return ( new SingleSideDiffElementViewModel(
|
|
344
|
-
originalModel,
|
|
345
|
-
modifiedModel,
|
|
346
|
-
originalModel.cells[diff.originalCellIndex],
|
|
347
|
-
undefined,
|
|
348
|
-
"delete",
|
|
349
|
-
this.eventDispatcher,
|
|
350
|
-
initData,
|
|
351
|
-
this.notebookService,
|
|
352
|
-
this.configurationService,
|
|
353
|
-
this.diffEditorHeightCalculator,
|
|
354
|
-
diff.originalCellIndex
|
|
355
|
-
));
|
|
356
|
-
}
|
|
357
|
-
case "insert":
|
|
358
|
-
{
|
|
359
|
-
return ( new SingleSideDiffElementViewModel(
|
|
360
|
-
modifiedModel,
|
|
361
|
-
originalModel,
|
|
362
|
-
undefined,
|
|
363
|
-
modifiedModel.cells[diff.modifiedCellIndex],
|
|
364
|
-
"insert",
|
|
365
|
-
this.eventDispatcher,
|
|
366
|
-
initData,
|
|
367
|
-
this.notebookService,
|
|
368
|
-
this.configurationService,
|
|
369
|
-
this.diffEditorHeightCalculator,
|
|
370
|
-
diff.modifiedCellIndex
|
|
371
|
-
));
|
|
372
|
-
}
|
|
373
|
-
case "modified":
|
|
374
|
-
{
|
|
375
|
-
const viewModel = ( new SideBySideDiffElementViewModel(
|
|
376
|
-
this.model.modified.notebook,
|
|
377
|
-
this.model.original.notebook,
|
|
378
|
-
originalModel.cells[diff.originalCellIndex],
|
|
379
|
-
modifiedModel.cells[diff.modifiedCellIndex],
|
|
380
|
-
"modified",
|
|
381
|
-
this.eventDispatcher,
|
|
382
|
-
initData,
|
|
383
|
-
this.notebookService,
|
|
384
|
-
this.configurationService,
|
|
385
|
-
diff.originalCellIndex,
|
|
386
|
-
this.diffEditorHeightCalculator
|
|
387
|
-
));
|
|
388
|
-
await viewModel.computeEditorHeights();
|
|
389
|
-
return viewModel;
|
|
390
|
-
}
|
|
391
|
-
case "unchanged":
|
|
392
|
-
{
|
|
393
|
-
return ( new SideBySideDiffElementViewModel(
|
|
394
|
-
this.model.modified.notebook,
|
|
395
|
-
this.model.original.notebook,
|
|
396
|
-
originalModel.cells[diff.originalCellIndex],
|
|
397
|
-
modifiedModel.cells[diff.modifiedCellIndex],
|
|
398
|
-
"unchanged",
|
|
399
|
-
this.eventDispatcher,
|
|
400
|
-
initData,
|
|
401
|
-
this.notebookService,
|
|
402
|
-
this.configurationService,
|
|
403
|
-
diff.originalCellIndex,
|
|
404
|
-
this.diffEditorHeightCalculator
|
|
405
|
-
));
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
})));
|
|
409
|
-
cellViewModels.forEach(vm => viewModels.push(vm));
|
|
410
|
-
return viewModels;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
function prettyChanges(original, modified, diffResult) {
|
|
414
|
-
const changes = diffResult.changes;
|
|
415
|
-
for (let i = 0; i < diffResult.changes.length - 1; i++) {
|
|
416
|
-
const curr = changes[i];
|
|
417
|
-
const next = changes[i + 1];
|
|
418
|
-
const x = curr.originalStart;
|
|
419
|
-
const y = curr.modifiedStart;
|
|
420
|
-
if (curr.originalLength === 1 && curr.modifiedLength === 0 && next.originalStart === x + 2 && next.originalLength === 0 && next.modifiedStart === y + 1 && next.modifiedLength === 1 && original.cells[x].getHashValue() === modified.cells[y + 1].getHashValue() && original.cells[x + 1].getHashValue() === modified.cells[y].getHashValue()) {
|
|
421
|
-
curr.originalStart = x;
|
|
422
|
-
curr.originalLength = 0;
|
|
423
|
-
curr.modifiedStart = y;
|
|
424
|
-
curr.modifiedLength = 1;
|
|
425
|
-
next.originalStart = x + 1;
|
|
426
|
-
next.originalLength = 1;
|
|
427
|
-
next.modifiedStart = y + 2;
|
|
428
|
-
next.modifiedLength = 0;
|
|
429
|
-
i++;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
function isEqual(cellDiffInfo, viewModels, model) {
|
|
434
|
-
if (cellDiffInfo.length !== viewModels.length) {
|
|
435
|
-
return false;
|
|
436
|
-
}
|
|
437
|
-
const originalModel = model.original.notebook;
|
|
438
|
-
const modifiedModel = model.modified.notebook;
|
|
439
|
-
for (let i = 0; i < viewModels.length; i++) {
|
|
440
|
-
const a = cellDiffInfo[i];
|
|
441
|
-
const b = viewModels[i];
|
|
442
|
-
if (a.type !== b.type) {
|
|
443
|
-
return false;
|
|
444
|
-
}
|
|
445
|
-
switch (a.type) {
|
|
446
|
-
case "delete":
|
|
447
|
-
{
|
|
448
|
-
if (originalModel.cells[a.originalCellIndex].handle !== b.original?.handle) {
|
|
449
|
-
return false;
|
|
450
|
-
}
|
|
451
|
-
continue;
|
|
452
|
-
}
|
|
453
|
-
case "insert":
|
|
454
|
-
{
|
|
455
|
-
if (modifiedModel.cells[a.modifiedCellIndex].handle !== b.modified?.handle) {
|
|
456
|
-
return false;
|
|
457
|
-
}
|
|
458
|
-
continue;
|
|
459
|
-
}
|
|
460
|
-
default:
|
|
461
|
-
{
|
|
462
|
-
if (originalModel.cells[a.originalCellIndex].handle !== b.original?.handle) {
|
|
463
|
-
return false;
|
|
464
|
-
}
|
|
465
|
-
if (modifiedModel.cells[a.modifiedCellIndex].handle !== b.modified?.handle) {
|
|
466
|
-
return false;
|
|
467
|
-
}
|
|
468
|
-
continue;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
class NotebookMultiDiffEditorItem extends MultiDiffEditorItem {
|
|
475
|
-
constructor(
|
|
476
|
-
originalUri,
|
|
477
|
-
modifiedUri,
|
|
478
|
-
goToFileUri,
|
|
479
|
-
type,
|
|
480
|
-
containerType,
|
|
481
|
-
kind,
|
|
482
|
-
contextKeys
|
|
483
|
-
) {
|
|
484
|
-
super(originalUri, modifiedUri, goToFileUri, undefined, contextKeys);
|
|
485
|
-
this.type = type;
|
|
486
|
-
this.containerType = containerType;
|
|
487
|
-
this.kind = kind;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
class NotebookMultiDiffEditorCellItem extends NotebookMultiDiffEditorItem {
|
|
491
|
-
constructor(originalUri, modifiedUri, type, containerType) {
|
|
492
|
-
super(
|
|
493
|
-
originalUri,
|
|
494
|
-
modifiedUri,
|
|
495
|
-
modifiedUri || originalUri,
|
|
496
|
-
type,
|
|
497
|
-
containerType,
|
|
498
|
-
"Cell",
|
|
499
|
-
{
|
|
500
|
-
[NOTEBOOK_DIFF_ITEM_KIND.key]: "Cell",
|
|
501
|
-
[NOTEBOOK_DIFF_ITEM_DIFF_STATE.key]: type
|
|
502
|
-
}
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
class NotebookMultiDiffEditorMetadataItem extends NotebookMultiDiffEditorItem {
|
|
507
|
-
constructor(originalUri, modifiedUri, type, containerType) {
|
|
508
|
-
super(
|
|
509
|
-
originalUri,
|
|
510
|
-
modifiedUri,
|
|
511
|
-
modifiedUri || originalUri,
|
|
512
|
-
type,
|
|
513
|
-
containerType,
|
|
514
|
-
"Metadata",
|
|
515
|
-
{
|
|
516
|
-
[NOTEBOOK_DIFF_ITEM_KIND.key]: "Metadata",
|
|
517
|
-
[NOTEBOOK_DIFF_ITEM_DIFF_STATE.key]: type
|
|
518
|
-
}
|
|
519
|
-
);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
class NotebookMultiDiffEditorOutputItem extends NotebookMultiDiffEditorItem {
|
|
523
|
-
constructor(originalUri, modifiedUri, type, containerType) {
|
|
524
|
-
super(
|
|
525
|
-
originalUri,
|
|
526
|
-
modifiedUri,
|
|
527
|
-
modifiedUri || originalUri,
|
|
528
|
-
type,
|
|
529
|
-
containerType,
|
|
530
|
-
"Output",
|
|
531
|
-
{
|
|
532
|
-
[NOTEBOOK_DIFF_ITEM_KIND.key]: "Output",
|
|
533
|
-
[NOTEBOOK_DIFF_ITEM_DIFF_STATE.key]: type
|
|
534
|
-
}
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
export { NotebookDiffViewModel, NotebookMultiDiffEditorItem, prettyChanges };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Event } from "../../../../../base/common/event.js";
|
|
2
|
-
import { IDisposable } from "../../../../../base/common/lifecycle.js";
|
|
3
|
-
import { IConfigurationService } from "../../../../../platform/configuration/common/configuration.service.js";
|
|
4
|
-
export type UnchangedEditorRegionOptions = {
|
|
5
|
-
options: {
|
|
6
|
-
enabled: boolean;
|
|
7
|
-
contextLineCount: number;
|
|
8
|
-
minimumLineCount: number;
|
|
9
|
-
revealLineCount: number;
|
|
10
|
-
};
|
|
11
|
-
readonly onDidChangeEnablement: Event<boolean>;
|
|
12
|
-
};
|
|
13
|
-
export declare function getUnchangedRegionSettings(configurationService: IConfigurationService): (Readonly<UnchangedEditorRegionOptions> & IDisposable);
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Emitter } from '../../../../../base/common/event.js';
|
|
3
|
-
import { DisposableStore } from '../../../../../base/common/lifecycle.js';
|
|
4
|
-
|
|
5
|
-
function getUnchangedRegionSettings(configurationService) {
|
|
6
|
-
return createHideUnchangedRegionOptions(configurationService);
|
|
7
|
-
}
|
|
8
|
-
function createHideUnchangedRegionOptions(configurationService) {
|
|
9
|
-
const disposables = ( new DisposableStore());
|
|
10
|
-
const unchangedRegionsEnablementEmitter = disposables.add(( new Emitter()));
|
|
11
|
-
const result = {
|
|
12
|
-
options: {
|
|
13
|
-
enabled: configurationService.getValue("diffEditor.hideUnchangedRegions.enabled"),
|
|
14
|
-
minimumLineCount: configurationService.getValue("diffEditor.hideUnchangedRegions.minimumLineCount"),
|
|
15
|
-
contextLineCount: configurationService.getValue("diffEditor.hideUnchangedRegions.contextLineCount"),
|
|
16
|
-
revealLineCount: configurationService.getValue("diffEditor.hideUnchangedRegions.revealLineCount")
|
|
17
|
-
},
|
|
18
|
-
onDidChangeEnablement: unchangedRegionsEnablementEmitter.event.bind(unchangedRegionsEnablementEmitter),
|
|
19
|
-
dispose: () => disposables.dispose()
|
|
20
|
-
};
|
|
21
|
-
disposables.add(configurationService.onDidChangeConfiguration(e => {
|
|
22
|
-
if (e.affectsConfiguration("diffEditor.hideUnchangedRegions.minimumLineCount")) {
|
|
23
|
-
result.options.minimumLineCount = configurationService.getValue("diffEditor.hideUnchangedRegions.minimumLineCount");
|
|
24
|
-
}
|
|
25
|
-
if (e.affectsConfiguration("diffEditor.hideUnchangedRegions.contextLineCount")) {
|
|
26
|
-
result.options.contextLineCount = configurationService.getValue("diffEditor.hideUnchangedRegions.contextLineCount");
|
|
27
|
-
}
|
|
28
|
-
if (e.affectsConfiguration("diffEditor.hideUnchangedRegions.revealLineCount")) {
|
|
29
|
-
result.options.revealLineCount = configurationService.getValue("diffEditor.hideUnchangedRegions.revealLineCount");
|
|
30
|
-
}
|
|
31
|
-
if (e.affectsConfiguration("diffEditor.hideUnchangedRegions.enabled")) {
|
|
32
|
-
result.options.enabled = configurationService.getValue("diffEditor.hideUnchangedRegions.enabled");
|
|
33
|
-
unchangedRegionsEnablementEmitter.fire(result.options.enabled);
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { getUnchangedRegionSettings };
|
package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { INotebookDocumentMetadataTextModel, INotebookTextModel, NotebookDocumentMetadata, TransientDocumentMetadata } from "../notebookCommon.js";
|
|
2
|
-
import { Disposable } from "../../../../../base/common/lifecycle.js";
|
|
3
|
-
import { URI } from "../../../../../base/common/uri.js";
|
|
4
|
-
import { ITextBuffer } from "../../../../../editor/common/model.js";
|
|
5
|
-
export declare function getFormattedNotebookMetadataJSON(transientMetadata: TransientDocumentMetadata | undefined, metadata: NotebookDocumentMetadata): string;
|
|
6
|
-
export declare class NotebookDocumentMetadataTextModel extends Disposable implements INotebookDocumentMetadataTextModel {
|
|
7
|
-
readonly notebookModel: INotebookTextModel;
|
|
8
|
-
readonly uri: URI;
|
|
9
|
-
get metadata(): NotebookDocumentMetadata;
|
|
10
|
-
private readonly _onDidChange;
|
|
11
|
-
readonly onDidChange: import("../../../../../base/common/event.js").Event<void>;
|
|
12
|
-
private _textBufferHash;
|
|
13
|
-
private _textBuffer?;
|
|
14
|
-
get textBuffer(): ITextBuffer;
|
|
15
|
-
constructor(notebookModel: INotebookTextModel);
|
|
16
|
-
getHash(): string;
|
|
17
|
-
getValue(): string;
|
|
18
|
-
private getFullModelRange;
|
|
19
|
-
}
|