@codingame/monaco-vscode-notebook-service-override 3.2.3 → 4.1.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.
Files changed (80) hide show
  1. package/notebook.js +13 -13
  2. package/package.json +2 -2
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/override/vs/platform/dialogs/common/dialogs.js +0 -8
  6. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +0 -6
  7. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +0 -389
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +0 -608
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +0 -109
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +0 -173
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +0 -488
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +0 -106
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +0 -67
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +0 -165
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +0 -67
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +0 -320
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +0 -72
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +0 -6
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +0 -168
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +0 -209
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +0 -84
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +0 -82
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +0 -67
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +0 -91
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +0 -393
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +0 -5
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +0 -97
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +0 -118
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +0 -59
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +0 -148
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +0 -383
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +0 -77
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +0 -511
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +0 -159
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +0 -56
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +0 -94
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +0 -51
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +0 -565
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +0 -31
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController.js +0 -744
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +0 -707
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -351
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +0 -267
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -45
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1297
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -284
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -563
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -108
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -39
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +0 -6
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +0 -313
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -890
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -13
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -393
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -175
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +0 -1174
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +0 -159
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +0 -451
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +0 -192
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +0 -106
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +0 -509
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +0 -130
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +0 -341
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +0 -111
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +0 -28
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +0 -65
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +0 -641
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +0 -200
  69. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +0 -80
  70. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +0 -1003
  71. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +0 -103
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +0 -202
  73. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +0 -80
  74. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +0 -98
  75. package/vscode/src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchService.js +0 -237
  76. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +0 -89
  77. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +0 -376
  78. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +0 -408
  79. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +0 -144
  80. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +0 -129
@@ -1,563 +0,0 @@
1
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
2
- import { hash } from 'vscode/vscode/vs/base/common/hash';
3
- import { toFormattedString } from 'vscode/vscode/vs/base/common/jsonFormatter';
4
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
- import { DiffEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/diffEditor/diffEditorWidget';
6
- import { fixedEditorPadding } from './diffCellEditorOptions.js';
7
- import { NotebookDiffViewEventType } from './eventDispatcher.js';
8
- import { DiffSide, DIFF_CELL_MARGIN } from './notebookDiffEditorBrowser.js';
9
- import { CellLayoutState } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
10
-
11
- var PropertyFoldingState;
12
- ( (function(PropertyFoldingState) {
13
- PropertyFoldingState[PropertyFoldingState["Expanded"] = 0] = "Expanded";
14
- PropertyFoldingState[PropertyFoldingState["Collapsed"] = 1] = "Collapsed";
15
- })(PropertyFoldingState || (PropertyFoldingState = {})));
16
- const OUTPUT_EDITOR_HEIGHT_MAGIC = 1440;
17
- class DiffElementViewModelBase extends Disposable {
18
- set rawOutputHeight(height) {
19
- this._layout({ rawOutputHeight: Math.min(OUTPUT_EDITOR_HEIGHT_MAGIC, height) });
20
- }
21
- get rawOutputHeight() {
22
- throw new Error('Use Cell.layoutInfo.rawOutputHeight');
23
- }
24
- set outputStatusHeight(height) {
25
- this._layout({ outputStatusHeight: height });
26
- }
27
- get outputStatusHeight() {
28
- throw new Error('Use Cell.layoutInfo.outputStatusHeight');
29
- }
30
- set outputMetadataHeight(height) {
31
- this._layout({ outputMetadataHeight: height });
32
- }
33
- get outputMetadataHeight() {
34
- throw new Error('Use Cell.layoutInfo.outputStatusHeight');
35
- }
36
- set editorHeight(height) {
37
- this._layout({ editorHeight: height });
38
- }
39
- get editorHeight() {
40
- throw new Error('Use Cell.layoutInfo.editorHeight');
41
- }
42
- set editorMargin(margin) {
43
- this._layout({ editorMargin: margin });
44
- }
45
- get editorMargin() {
46
- throw new Error('Use Cell.layoutInfo.editorMargin');
47
- }
48
- set metadataStatusHeight(height) {
49
- this._layout({ metadataStatusHeight: height });
50
- }
51
- get metadataStatusHeight() {
52
- throw new Error('Use Cell.layoutInfo.outputStatusHeight');
53
- }
54
- set metadataHeight(height) {
55
- this._layout({ metadataHeight: height });
56
- }
57
- get metadataHeight() {
58
- throw new Error('Use Cell.layoutInfo.metadataHeight');
59
- }
60
- set renderOutput(value) {
61
- this._renderOutput = value;
62
- this._layout({ recomputeOutput: true });
63
- this._stateChangeEmitter.fire({ renderOutput: this._renderOutput });
64
- }
65
- get renderOutput() {
66
- return this._renderOutput;
67
- }
68
- get layoutInfo() {
69
- return this._layoutInfo;
70
- }
71
- constructor(mainDocumentTextModel, original, modified, type, editorEventDispatcher, initData) {
72
- super();
73
- this.mainDocumentTextModel = mainDocumentTextModel;
74
- this.original = original;
75
- this.modified = modified;
76
- this.type = type;
77
- this.editorEventDispatcher = editorEventDispatcher;
78
- this.initData = initData;
79
- this._layoutInfoEmitter = this._register(( new Emitter()));
80
- this.onDidLayoutChange = this._layoutInfoEmitter.event;
81
- this._stateChangeEmitter = this._register(( new Emitter()));
82
- this.onDidStateChange = this._stateChangeEmitter.event;
83
- this._renderOutput = true;
84
- this._sourceEditorViewState = null;
85
- this._outputEditorViewState = null;
86
- this._metadataEditorViewState = null;
87
- const editorHeight = this._estimateEditorHeight(initData.fontInfo);
88
- this._layoutInfo = {
89
- width: 0,
90
- editorHeight: editorHeight,
91
- editorMargin: 0,
92
- metadataHeight: 0,
93
- metadataStatusHeight: 25,
94
- rawOutputHeight: 0,
95
- outputTotalHeight: 0,
96
- outputStatusHeight: 25,
97
- outputMetadataHeight: 0,
98
- bodyMargin: 32,
99
- totalHeight: 82 + editorHeight,
100
- layoutState: CellLayoutState.Uninitialized
101
- };
102
- this.metadataFoldingState = PropertyFoldingState.Collapsed;
103
- this.outputFoldingState = PropertyFoldingState.Collapsed;
104
- this._register(this.editorEventDispatcher.onDidChangeLayout(e => {
105
- this._layoutInfoEmitter.fire({ outerWidth: true });
106
- }));
107
- }
108
- layoutChange() {
109
- this._layout({ recomputeOutput: true });
110
- }
111
- _estimateEditorHeight(fontInfo) {
112
- const lineHeight = fontInfo?.lineHeight ?? 17;
113
- switch (this.type) {
114
- case 'unchanged':
115
- case 'insert':
116
- {
117
- const lineCount = this.modified.textModel.textBuffer.getLineCount();
118
- const editorHeight = lineCount * lineHeight + fixedEditorPadding.top + fixedEditorPadding.bottom;
119
- return editorHeight;
120
- }
121
- case 'delete':
122
- case 'modified':
123
- {
124
- const lineCount = this.original.textModel.textBuffer.getLineCount();
125
- const editorHeight = lineCount * lineHeight + fixedEditorPadding.top + fixedEditorPadding.bottom;
126
- return editorHeight;
127
- }
128
- }
129
- }
130
- _layout(delta) {
131
- const width = delta.width !== undefined ? delta.width : this._layoutInfo.width;
132
- const editorHeight = delta.editorHeight !== undefined ? delta.editorHeight : this._layoutInfo.editorHeight;
133
- const editorMargin = delta.editorMargin !== undefined ? delta.editorMargin : this._layoutInfo.editorMargin;
134
- const metadataHeight = delta.metadataHeight !== undefined ? delta.metadataHeight : this._layoutInfo.metadataHeight;
135
- const metadataStatusHeight = delta.metadataStatusHeight !== undefined ? delta.metadataStatusHeight : this._layoutInfo.metadataStatusHeight;
136
- const rawOutputHeight = delta.rawOutputHeight !== undefined ? delta.rawOutputHeight : this._layoutInfo.rawOutputHeight;
137
- const outputStatusHeight = delta.outputStatusHeight !== undefined ? delta.outputStatusHeight : this._layoutInfo.outputStatusHeight;
138
- const bodyMargin = delta.bodyMargin !== undefined ? delta.bodyMargin : this._layoutInfo.bodyMargin;
139
- const outputMetadataHeight = delta.outputMetadataHeight !== undefined ? delta.outputMetadataHeight : this._layoutInfo.outputMetadataHeight;
140
- const outputHeight = (delta.recomputeOutput || delta.rawOutputHeight !== undefined || delta.outputMetadataHeight !== undefined) ? this._getOutputTotalHeight(rawOutputHeight, outputMetadataHeight) : this._layoutInfo.outputTotalHeight;
141
- const totalHeight = editorHeight
142
- + editorMargin
143
- + metadataHeight
144
- + metadataStatusHeight
145
- + outputHeight
146
- + outputStatusHeight
147
- + bodyMargin;
148
- const newLayout = {
149
- width: width,
150
- editorHeight: editorHeight,
151
- editorMargin: editorMargin,
152
- metadataHeight: metadataHeight,
153
- metadataStatusHeight: metadataStatusHeight,
154
- outputTotalHeight: outputHeight,
155
- outputStatusHeight: outputStatusHeight,
156
- bodyMargin: bodyMargin,
157
- rawOutputHeight: rawOutputHeight,
158
- outputMetadataHeight: outputMetadataHeight,
159
- totalHeight: totalHeight,
160
- layoutState: CellLayoutState.Measured
161
- };
162
- let somethingChanged = false;
163
- const changeEvent = {};
164
- if (newLayout.width !== this._layoutInfo.width) {
165
- changeEvent.width = true;
166
- somethingChanged = true;
167
- }
168
- if (newLayout.editorHeight !== this._layoutInfo.editorHeight) {
169
- changeEvent.editorHeight = true;
170
- somethingChanged = true;
171
- }
172
- if (newLayout.editorMargin !== this._layoutInfo.editorMargin) {
173
- changeEvent.editorMargin = true;
174
- somethingChanged = true;
175
- }
176
- if (newLayout.metadataHeight !== this._layoutInfo.metadataHeight) {
177
- changeEvent.metadataHeight = true;
178
- somethingChanged = true;
179
- }
180
- if (newLayout.metadataStatusHeight !== this._layoutInfo.metadataStatusHeight) {
181
- changeEvent.metadataStatusHeight = true;
182
- somethingChanged = true;
183
- }
184
- if (newLayout.outputTotalHeight !== this._layoutInfo.outputTotalHeight) {
185
- changeEvent.outputTotalHeight = true;
186
- somethingChanged = true;
187
- }
188
- if (newLayout.outputStatusHeight !== this._layoutInfo.outputStatusHeight) {
189
- changeEvent.outputStatusHeight = true;
190
- somethingChanged = true;
191
- }
192
- if (newLayout.bodyMargin !== this._layoutInfo.bodyMargin) {
193
- changeEvent.bodyMargin = true;
194
- somethingChanged = true;
195
- }
196
- if (newLayout.outputMetadataHeight !== this._layoutInfo.outputMetadataHeight) {
197
- changeEvent.outputMetadataHeight = true;
198
- somethingChanged = true;
199
- }
200
- if (newLayout.totalHeight !== this._layoutInfo.totalHeight) {
201
- changeEvent.totalHeight = true;
202
- somethingChanged = true;
203
- }
204
- if (somethingChanged) {
205
- this._layoutInfo = newLayout;
206
- this._fireLayoutChangeEvent(changeEvent);
207
- }
208
- }
209
- getHeight(lineHeight) {
210
- if (this._layoutInfo.layoutState === CellLayoutState.Uninitialized) {
211
- const editorHeight = this.estimateEditorHeight(lineHeight);
212
- return this._computeTotalHeight(editorHeight);
213
- }
214
- else {
215
- return this._layoutInfo.totalHeight;
216
- }
217
- }
218
- _computeTotalHeight(editorHeight) {
219
- const totalHeight = editorHeight
220
- + this._layoutInfo.editorMargin
221
- + this._layoutInfo.metadataHeight
222
- + this._layoutInfo.metadataStatusHeight
223
- + this._layoutInfo.outputTotalHeight
224
- + this._layoutInfo.outputStatusHeight
225
- + this._layoutInfo.outputMetadataHeight
226
- + this._layoutInfo.bodyMargin;
227
- return totalHeight;
228
- }
229
- estimateEditorHeight(lineHeight = 20) {
230
- const verticalScrollbarHeight = 0;
231
- const lineCount = Math.max(this.original?.textModel.textBuffer.getLineCount() ?? 1, this.modified?.textModel.textBuffer.getLineCount() ?? 1);
232
- return lineCount * lineHeight
233
- + 24
234
- + 12
235
- + verticalScrollbarHeight;
236
- }
237
- _getOutputTotalHeight(rawOutputHeight, metadataHeight) {
238
- if (this.outputFoldingState === PropertyFoldingState.Collapsed) {
239
- return 0;
240
- }
241
- if (this.renderOutput) {
242
- if (this.isOutputEmpty()) {
243
- return 24;
244
- }
245
- return this.getRichOutputTotalHeight() + metadataHeight;
246
- }
247
- else {
248
- return rawOutputHeight;
249
- }
250
- }
251
- _fireLayoutChangeEvent(state) {
252
- this._layoutInfoEmitter.fire(state);
253
- this.editorEventDispatcher.emit([{ type: NotebookDiffViewEventType.CellLayoutChanged, source: this._layoutInfo }]);
254
- }
255
- getComputedCellContainerWidth(layoutInfo, diffEditor, fullWidth) {
256
- if (fullWidth) {
257
- return layoutInfo.width - 2 * DIFF_CELL_MARGIN + (diffEditor ? DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH : 0) - 2;
258
- }
259
- return (layoutInfo.width - 2 * DIFF_CELL_MARGIN + (diffEditor ? DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH : 0)) / 2 - 18 - 2;
260
- }
261
- getOutputEditorViewState() {
262
- return this._outputEditorViewState;
263
- }
264
- saveOutputEditorViewState(viewState) {
265
- this._outputEditorViewState = viewState;
266
- }
267
- getMetadataEditorViewState() {
268
- return this._metadataEditorViewState;
269
- }
270
- saveMetadataEditorViewState(viewState) {
271
- this._metadataEditorViewState = viewState;
272
- }
273
- getSourceEditorViewState() {
274
- return this._sourceEditorViewState;
275
- }
276
- saveSpirceEditorViewState(viewState) {
277
- this._sourceEditorViewState = viewState;
278
- }
279
- }
280
- class SideBySideDiffElementViewModel extends DiffElementViewModelBase {
281
- get originalDocument() {
282
- return this.otherDocumentTextModel;
283
- }
284
- get modifiedDocument() {
285
- return this.mainDocumentTextModel;
286
- }
287
- constructor(mainDocumentTextModel, otherDocumentTextModel, original, modified, type, editorEventDispatcher, initData) {
288
- super(mainDocumentTextModel, original, modified, type, editorEventDispatcher, initData);
289
- this.otherDocumentTextModel = otherDocumentTextModel;
290
- this.original = original;
291
- this.modified = modified;
292
- this.type = type;
293
- this.metadataFoldingState = PropertyFoldingState.Collapsed;
294
- this.outputFoldingState = PropertyFoldingState.Collapsed;
295
- if (this.checkMetadataIfModified()) {
296
- this.metadataFoldingState = PropertyFoldingState.Expanded;
297
- }
298
- if (this.checkIfOutputsModified()) {
299
- this.outputFoldingState = PropertyFoldingState.Expanded;
300
- }
301
- this._register(this.original.onDidChangeOutputLayout(() => {
302
- this._layout({ recomputeOutput: true });
303
- }));
304
- this._register(this.modified.onDidChangeOutputLayout(() => {
305
- this._layout({ recomputeOutput: true });
306
- }));
307
- this._register(this.modified.textModel.onDidChangeContent(() => {
308
- if (mainDocumentTextModel.transientOptions.cellContentMetadata) {
309
- const cellMetadataKeys = [...( Object.keys(mainDocumentTextModel.transientOptions.cellContentMetadata))];
310
- const modifiedMedataRaw = Object.assign({}, this.modified.metadata);
311
- const originalCellMetadata = this.original.metadata;
312
- for (const key of cellMetadataKeys) {
313
- modifiedMedataRaw[key] = originalCellMetadata[key];
314
- }
315
- this.modified.textModel.metadata = modifiedMedataRaw;
316
- }
317
- }));
318
- }
319
- checkIfOutputsModified() {
320
- if (this.mainDocumentTextModel.transientOptions.transientOutputs) {
321
- return false;
322
- }
323
- const ret = outputsEqual(this.original?.outputs ?? [], this.modified?.outputs ?? []);
324
- if (ret === 0 ) {
325
- return false;
326
- }
327
- return {
328
- reason: ret === 1 ? 'Output metadata is changed' : undefined,
329
- kind: ret
330
- };
331
- }
332
- checkMetadataIfModified() {
333
- const modified = hash(getFormattedMetadataJSON(this.mainDocumentTextModel, this.original?.metadata || {}, this.original?.language)) !== hash(getFormattedMetadataJSON(this.mainDocumentTextModel, this.modified?.metadata ?? {}, this.modified?.language));
334
- if (modified) {
335
- return { reason: undefined };
336
- }
337
- else {
338
- return false;
339
- }
340
- }
341
- updateOutputHeight(diffSide, index, height) {
342
- if (diffSide === DiffSide.Original) {
343
- this.original.updateOutputHeight(index, height);
344
- }
345
- else {
346
- this.modified.updateOutputHeight(index, height);
347
- }
348
- }
349
- getOutputOffsetInContainer(diffSide, index) {
350
- if (diffSide === DiffSide.Original) {
351
- return this.original.getOutputOffset(index);
352
- }
353
- else {
354
- return this.modified.getOutputOffset(index);
355
- }
356
- }
357
- getOutputOffsetInCell(diffSide, index) {
358
- const offsetInOutputsContainer = this.getOutputOffsetInContainer(diffSide, index);
359
- return this._layoutInfo.editorHeight
360
- + this._layoutInfo.editorMargin
361
- + this._layoutInfo.metadataHeight
362
- + this._layoutInfo.metadataStatusHeight
363
- + this._layoutInfo.outputStatusHeight
364
- + this._layoutInfo.bodyMargin / 2
365
- + offsetInOutputsContainer;
366
- }
367
- isOutputEmpty() {
368
- if (this.mainDocumentTextModel.transientOptions.transientOutputs) {
369
- return true;
370
- }
371
- if (this.checkIfOutputsModified()) {
372
- return false;
373
- }
374
- return (this.original?.outputs || []).length === 0;
375
- }
376
- getRichOutputTotalHeight() {
377
- return Math.max(this.original.getOutputTotalHeight(), this.modified.getOutputTotalHeight());
378
- }
379
- getNestedCellViewModel(diffSide) {
380
- return diffSide === DiffSide.Original ? this.original : this.modified;
381
- }
382
- getCellByUri(cellUri) {
383
- if (( cellUri.toString()) === ( this.original.uri.toString())) {
384
- return this.original;
385
- }
386
- else {
387
- return this.modified;
388
- }
389
- }
390
- }
391
- class SingleSideDiffElementViewModel extends DiffElementViewModelBase {
392
- get cellViewModel() {
393
- return this.type === 'insert' ? this.modified : this.original;
394
- }
395
- get originalDocument() {
396
- if (this.type === 'insert') {
397
- return this.otherDocumentTextModel;
398
- }
399
- else {
400
- return this.mainDocumentTextModel;
401
- }
402
- }
403
- get modifiedDocument() {
404
- if (this.type === 'insert') {
405
- return this.mainDocumentTextModel;
406
- }
407
- else {
408
- return this.otherDocumentTextModel;
409
- }
410
- }
411
- constructor(mainDocumentTextModel, otherDocumentTextModel, original, modified, type, editorEventDispatcher, initData) {
412
- super(mainDocumentTextModel, original, modified, type, editorEventDispatcher, initData);
413
- this.otherDocumentTextModel = otherDocumentTextModel;
414
- this.type = type;
415
- this._register(this.cellViewModel.onDidChangeOutputLayout(() => {
416
- this._layout({ recomputeOutput: true });
417
- }));
418
- }
419
- getNestedCellViewModel(diffSide) {
420
- return this.type === 'insert' ? this.modified : this.original;
421
- }
422
- checkIfOutputsModified() {
423
- return false;
424
- }
425
- checkMetadataIfModified() {
426
- return false;
427
- }
428
- updateOutputHeight(diffSide, index, height) {
429
- this.cellViewModel?.updateOutputHeight(index, height);
430
- }
431
- getOutputOffsetInContainer(diffSide, index) {
432
- return this.cellViewModel.getOutputOffset(index);
433
- }
434
- getOutputOffsetInCell(diffSide, index) {
435
- const offsetInOutputsContainer = this.cellViewModel.getOutputOffset(index);
436
- return this._layoutInfo.editorHeight
437
- + this._layoutInfo.editorMargin
438
- + this._layoutInfo.metadataHeight
439
- + this._layoutInfo.metadataStatusHeight
440
- + this._layoutInfo.outputStatusHeight
441
- + this._layoutInfo.bodyMargin / 2
442
- + offsetInOutputsContainer;
443
- }
444
- isOutputEmpty() {
445
- if (this.mainDocumentTextModel.transientOptions.transientOutputs) {
446
- return true;
447
- }
448
- return (this.original?.outputs || this.modified?.outputs || []).length === 0;
449
- }
450
- getRichOutputTotalHeight() {
451
- return this.cellViewModel?.getOutputTotalHeight() ?? 0;
452
- }
453
- getCellByUri(cellUri) {
454
- return this.cellViewModel;
455
- }
456
- }
457
- function outputEqual(a, b) {
458
- if (hash(a.metadata) === hash(b.metadata)) {
459
- return 2 ;
460
- }
461
- for (let j = 0; j < a.outputs.length; j++) {
462
- const aOutputItem = a.outputs[j];
463
- const bOutputItem = b.outputs[j];
464
- if (aOutputItem.mime !== bOutputItem.mime) {
465
- return 2 ;
466
- }
467
- if (aOutputItem.data.buffer.length !== bOutputItem.data.buffer.length) {
468
- return 2 ;
469
- }
470
- for (let k = 0; k < aOutputItem.data.buffer.length; k++) {
471
- if (aOutputItem.data.buffer[k] !== bOutputItem.data.buffer[k]) {
472
- return 2 ;
473
- }
474
- }
475
- }
476
- return 1 ;
477
- }
478
- function outputsEqual(original, modified) {
479
- if (original.length !== modified.length) {
480
- return 2 ;
481
- }
482
- const len = original.length;
483
- for (let i = 0; i < len; i++) {
484
- const a = original[i];
485
- const b = modified[i];
486
- if (hash(a.metadata) !== hash(b.metadata)) {
487
- return 1 ;
488
- }
489
- if (a.outputs.length !== b.outputs.length) {
490
- return 2 ;
491
- }
492
- for (let j = 0; j < a.outputs.length; j++) {
493
- const aOutputItem = a.outputs[j];
494
- const bOutputItem = b.outputs[j];
495
- if (aOutputItem.mime !== bOutputItem.mime) {
496
- return 2 ;
497
- }
498
- if (aOutputItem.data.buffer.length !== bOutputItem.data.buffer.length) {
499
- return 2 ;
500
- }
501
- for (let k = 0; k < aOutputItem.data.buffer.length; k++) {
502
- if (aOutputItem.data.buffer[k] !== bOutputItem.data.buffer[k]) {
503
- return 2 ;
504
- }
505
- }
506
- }
507
- }
508
- return 0 ;
509
- }
510
- function getFormattedMetadataJSON(documentTextModel, metadata, language) {
511
- let filteredMetadata = {};
512
- if (documentTextModel) {
513
- const transientCellMetadata = documentTextModel.transientOptions.transientCellMetadata;
514
- const keys = ( new Set([...( Object.keys(metadata))]));
515
- for (const key of keys) {
516
- if (!(transientCellMetadata[key])) {
517
- filteredMetadata[key] = metadata[key];
518
- }
519
- }
520
- }
521
- else {
522
- filteredMetadata = metadata;
523
- }
524
- const obj = {
525
- language,
526
- ...filteredMetadata
527
- };
528
- const metadataSource = toFormattedString(obj, {});
529
- return metadataSource;
530
- }
531
- function getStreamOutputData(outputs) {
532
- if (!outputs.length) {
533
- return null;
534
- }
535
- const first = outputs[0];
536
- const mime = first.mime;
537
- const sameStream = !outputs.find(op => op.mime !== mime);
538
- if (sameStream) {
539
- return ( outputs.map(opit => ( opit.data.toString()))).join('');
540
- }
541
- else {
542
- return null;
543
- }
544
- }
545
- function getFormattedOutputJSON(outputs) {
546
- if (outputs.length === 1) {
547
- const streamOutputData = getStreamOutputData(outputs[0].outputs);
548
- if (streamOutputData) {
549
- return streamOutputData;
550
- }
551
- }
552
- return JSON.stringify(( outputs.map(output => {
553
- return ({
554
- metadata: output.metadata,
555
- outputItems: ( output.outputs.map(opit => ({
556
- mimeType: opit.mime,
557
- data: ( opit.data.toString())
558
- })))
559
- });
560
- })), undefined, '\t');
561
- }
562
-
563
- export { DiffElementViewModelBase, OUTPUT_EDITOR_HEIGHT_MAGIC, PropertyFoldingState, SideBySideDiffElementViewModel, SingleSideDiffElementViewModel, getFormattedMetadataJSON, getFormattedOutputJSON, getStreamOutputData, outputEqual };
@@ -1,108 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
5
- import { PrefixSumComputer } from 'vscode/vscode/vs/editor/common/model/prefixSumComputer';
6
- import { CellOutputViewModel } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel';
7
- import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
8
-
9
- let DiffNestedCellViewModel = class DiffNestedCellViewModel extends Disposable {
10
- get id() {
11
- return this._id;
12
- }
13
- get outputs() {
14
- return this.textModel.outputs;
15
- }
16
- get language() {
17
- return this.textModel.language;
18
- }
19
- get metadata() {
20
- return this.textModel.metadata;
21
- }
22
- get uri() {
23
- return this.textModel.uri;
24
- }
25
- get handle() {
26
- return this.textModel.handle;
27
- }
28
- get outputIsHovered() {
29
- return this._hoveringOutput;
30
- }
31
- set outputIsHovered(v) {
32
- this._hoveringOutput = v;
33
- this._onDidChangeState.fire({ outputIsHoveredChanged: true });
34
- }
35
- get outputIsFocused() {
36
- return this._focusOnOutput;
37
- }
38
- set outputIsFocused(v) {
39
- this._focusOnOutput = v;
40
- this._onDidChangeState.fire({ outputIsFocusedChanged: true });
41
- }
42
- get outputsViewModels() {
43
- return this._outputViewModels;
44
- }
45
- constructor(textModel, _notebookService) {
46
- super();
47
- this.textModel = textModel;
48
- this._notebookService = _notebookService;
49
- this._onDidChangeState = this._register(( new Emitter()));
50
- this._hoveringOutput = false;
51
- this._focusOnOutput = false;
52
- this._outputCollection = [];
53
- this._outputsTop = null;
54
- this._onDidChangeOutputLayout = this._register(( new Emitter()));
55
- this.onDidChangeOutputLayout = this._onDidChangeOutputLayout.event;
56
- this._id = generateUuid();
57
- this._outputViewModels = ( this.textModel.outputs.map(output => ( new CellOutputViewModel(this, output, this._notebookService))));
58
- this._register(this.textModel.onDidChangeOutputs((splice) => {
59
- this._outputCollection.splice(splice.start, splice.deleteCount, ...( splice.newOutputs.map(() => 0)));
60
- const removed = this._outputViewModels.splice(splice.start, splice.deleteCount, ...( splice.newOutputs.map(output => ( new CellOutputViewModel(this, output, this._notebookService)))));
61
- removed.forEach(vm => vm.dispose());
62
- this._outputsTop = null;
63
- this._onDidChangeOutputLayout.fire();
64
- }));
65
- this._outputCollection = ( new Array(this.textModel.outputs.length));
66
- }
67
- _ensureOutputsTop() {
68
- if (!this._outputsTop) {
69
- const values = ( new Uint32Array(this._outputCollection.length));
70
- for (let i = 0; i < this._outputCollection.length; i++) {
71
- values[i] = this._outputCollection[i];
72
- }
73
- this._outputsTop = ( new PrefixSumComputer(values));
74
- }
75
- }
76
- getOutputOffset(index) {
77
- this._ensureOutputsTop();
78
- if (index >= this._outputCollection.length) {
79
- throw new Error('Output index out of range!');
80
- }
81
- return this._outputsTop.getPrefixSum(index - 1);
82
- }
83
- updateOutputHeight(index, height) {
84
- if (index >= this._outputCollection.length) {
85
- throw new Error('Output index out of range!');
86
- }
87
- this._ensureOutputsTop();
88
- this._outputCollection[index] = height;
89
- if (this._outputsTop.setValue(index, height)) {
90
- this._onDidChangeOutputLayout.fire();
91
- }
92
- }
93
- getOutputTotalHeight() {
94
- this._ensureOutputsTop();
95
- return this._outputsTop?.getTotalSum() ?? 0;
96
- }
97
- dispose() {
98
- super.dispose();
99
- this._outputViewModels.forEach(output => {
100
- output.dispose();
101
- });
102
- }
103
- };
104
- DiffNestedCellViewModel = ( __decorate([
105
- ( __param(1, INotebookService))
106
- ], DiffNestedCellViewModel));
107
-
108
- export { DiffNestedCellViewModel };