@codingame/monaco-vscode-notebook-service-override 8.0.4 → 9.0.2
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 +3 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +8 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +21 -21
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +26 -24
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +624 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +13 -13
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +4 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +9 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +12 -12
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +24 -24
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +54 -55
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +22 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +24 -24
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +23 -21
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +7 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +12 -12
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +297 -21
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +124 -73
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +27 -19
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +33 -33
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +62 -39
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +7 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +7 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +18 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +15 -40
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +0 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +28 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +55 -45
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +6 -6
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +12 -12
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -47
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1303
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -267
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -569
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -115
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -39
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -903
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -13
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -397
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -186
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +0 -107
|
@@ -1,569 +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 { DIFF_CELL_MARGIN, DiffSide } 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 === OutputComparison.Unchanged) {
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
return {
|
|
328
|
-
reason: ret === OutputComparison.Metadata ? '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
|
-
var OutputComparison;
|
|
458
|
-
( (function(OutputComparison) {
|
|
459
|
-
OutputComparison[OutputComparison["Unchanged"] = 0] = "Unchanged";
|
|
460
|
-
OutputComparison[OutputComparison["Metadata"] = 1] = "Metadata";
|
|
461
|
-
OutputComparison[OutputComparison["Other"] = 2] = "Other";
|
|
462
|
-
})(OutputComparison || (OutputComparison = {})));
|
|
463
|
-
function outputEqual(a, b) {
|
|
464
|
-
if (hash(a.metadata) === hash(b.metadata)) {
|
|
465
|
-
return OutputComparison.Other;
|
|
466
|
-
}
|
|
467
|
-
for (let j = 0; j < a.outputs.length; j++) {
|
|
468
|
-
const aOutputItem = a.outputs[j];
|
|
469
|
-
const bOutputItem = b.outputs[j];
|
|
470
|
-
if (aOutputItem.mime !== bOutputItem.mime) {
|
|
471
|
-
return OutputComparison.Other;
|
|
472
|
-
}
|
|
473
|
-
if (aOutputItem.data.buffer.length !== bOutputItem.data.buffer.length) {
|
|
474
|
-
return OutputComparison.Other;
|
|
475
|
-
}
|
|
476
|
-
for (let k = 0; k < aOutputItem.data.buffer.length; k++) {
|
|
477
|
-
if (aOutputItem.data.buffer[k] !== bOutputItem.data.buffer[k]) {
|
|
478
|
-
return OutputComparison.Other;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
return OutputComparison.Metadata;
|
|
483
|
-
}
|
|
484
|
-
function outputsEqual(original, modified) {
|
|
485
|
-
if (original.length !== modified.length) {
|
|
486
|
-
return OutputComparison.Other;
|
|
487
|
-
}
|
|
488
|
-
const len = original.length;
|
|
489
|
-
for (let i = 0; i < len; i++) {
|
|
490
|
-
const a = original[i];
|
|
491
|
-
const b = modified[i];
|
|
492
|
-
if (hash(a.metadata) !== hash(b.metadata)) {
|
|
493
|
-
return OutputComparison.Metadata;
|
|
494
|
-
}
|
|
495
|
-
if (a.outputs.length !== b.outputs.length) {
|
|
496
|
-
return OutputComparison.Other;
|
|
497
|
-
}
|
|
498
|
-
for (let j = 0; j < a.outputs.length; j++) {
|
|
499
|
-
const aOutputItem = a.outputs[j];
|
|
500
|
-
const bOutputItem = b.outputs[j];
|
|
501
|
-
if (aOutputItem.mime !== bOutputItem.mime) {
|
|
502
|
-
return OutputComparison.Other;
|
|
503
|
-
}
|
|
504
|
-
if (aOutputItem.data.buffer.length !== bOutputItem.data.buffer.length) {
|
|
505
|
-
return OutputComparison.Other;
|
|
506
|
-
}
|
|
507
|
-
for (let k = 0; k < aOutputItem.data.buffer.length; k++) {
|
|
508
|
-
if (aOutputItem.data.buffer[k] !== bOutputItem.data.buffer[k]) {
|
|
509
|
-
return OutputComparison.Other;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
return OutputComparison.Unchanged;
|
|
515
|
-
}
|
|
516
|
-
function getFormattedMetadataJSON(documentTextModel, metadata, language) {
|
|
517
|
-
let filteredMetadata = {};
|
|
518
|
-
if (documentTextModel) {
|
|
519
|
-
const transientCellMetadata = documentTextModel.transientOptions.transientCellMetadata;
|
|
520
|
-
const keys = ( new Set([...( Object.keys(metadata))]));
|
|
521
|
-
for (const key of keys) {
|
|
522
|
-
if (!(transientCellMetadata[key])) {
|
|
523
|
-
filteredMetadata[key] = metadata[key];
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
filteredMetadata = metadata;
|
|
529
|
-
}
|
|
530
|
-
const obj = {
|
|
531
|
-
language,
|
|
532
|
-
...filteredMetadata
|
|
533
|
-
};
|
|
534
|
-
const metadataSource = toFormattedString(obj, {});
|
|
535
|
-
return metadataSource;
|
|
536
|
-
}
|
|
537
|
-
function getStreamOutputData(outputs) {
|
|
538
|
-
if (!outputs.length) {
|
|
539
|
-
return null;
|
|
540
|
-
}
|
|
541
|
-
const first = outputs[0];
|
|
542
|
-
const mime = first.mime;
|
|
543
|
-
const sameStream = !outputs.find(op => op.mime !== mime);
|
|
544
|
-
if (sameStream) {
|
|
545
|
-
return ( outputs.map(opit => ( opit.data.toString()))).join('');
|
|
546
|
-
}
|
|
547
|
-
else {
|
|
548
|
-
return null;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
function getFormattedOutputJSON(outputs) {
|
|
552
|
-
if (outputs.length === 1) {
|
|
553
|
-
const streamOutputData = getStreamOutputData(outputs[0].outputs);
|
|
554
|
-
if (streamOutputData) {
|
|
555
|
-
return streamOutputData;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
return JSON.stringify(( outputs.map(output => {
|
|
559
|
-
return ({
|
|
560
|
-
metadata: output.metadata,
|
|
561
|
-
outputItems: ( output.outputs.map(opit => ({
|
|
562
|
-
mimeType: opit.mime,
|
|
563
|
-
data: ( opit.data.toString())
|
|
564
|
-
})))
|
|
565
|
-
});
|
|
566
|
-
})), undefined, '\t');
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
export { DiffElementViewModelBase, OUTPUT_EDITOR_HEIGHT_MAGIC, OutputComparison, PropertyFoldingState, SideBySideDiffElementViewModel, SingleSideDiffElementViewModel, getFormattedMetadataJSON, getFormattedOutputJSON, getStreamOutputData, outputEqual };
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from 'vscode/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.service';
|
|
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 inputInOutputIsFocused() {
|
|
43
|
-
return this._focusInputInOutput;
|
|
44
|
-
}
|
|
45
|
-
set inputInOutputIsFocused(v) {
|
|
46
|
-
this._focusInputInOutput = v;
|
|
47
|
-
}
|
|
48
|
-
get outputsViewModels() {
|
|
49
|
-
return this._outputViewModels;
|
|
50
|
-
}
|
|
51
|
-
constructor(textModel, _notebookService) {
|
|
52
|
-
super();
|
|
53
|
-
this.textModel = textModel;
|
|
54
|
-
this._notebookService = _notebookService;
|
|
55
|
-
this._onDidChangeState = this._register(( new Emitter()));
|
|
56
|
-
this._hoveringOutput = false;
|
|
57
|
-
this._focusOnOutput = false;
|
|
58
|
-
this._focusInputInOutput = false;
|
|
59
|
-
this._outputCollection = [];
|
|
60
|
-
this._outputsTop = null;
|
|
61
|
-
this._onDidChangeOutputLayout = this._register(( new Emitter()));
|
|
62
|
-
this.onDidChangeOutputLayout = this._onDidChangeOutputLayout.event;
|
|
63
|
-
this._id = generateUuid();
|
|
64
|
-
this._outputViewModels = ( this.textModel.outputs.map(output => ( new CellOutputViewModel(this, output, this._notebookService))));
|
|
65
|
-
this._register(this.textModel.onDidChangeOutputs((splice) => {
|
|
66
|
-
this._outputCollection.splice(splice.start, splice.deleteCount, ...( splice.newOutputs.map(() => 0)));
|
|
67
|
-
const removed = this._outputViewModels.splice(splice.start, splice.deleteCount, ...( splice.newOutputs.map(output => ( new CellOutputViewModel(this, output, this._notebookService)))));
|
|
68
|
-
removed.forEach(vm => vm.dispose());
|
|
69
|
-
this._outputsTop = null;
|
|
70
|
-
this._onDidChangeOutputLayout.fire();
|
|
71
|
-
}));
|
|
72
|
-
this._outputCollection = ( new Array(this.textModel.outputs.length));
|
|
73
|
-
}
|
|
74
|
-
_ensureOutputsTop() {
|
|
75
|
-
if (!this._outputsTop) {
|
|
76
|
-
const values = ( new Uint32Array(this._outputCollection.length));
|
|
77
|
-
for (let i = 0; i < this._outputCollection.length; i++) {
|
|
78
|
-
values[i] = this._outputCollection[i];
|
|
79
|
-
}
|
|
80
|
-
this._outputsTop = ( new PrefixSumComputer(values));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
getOutputOffset(index) {
|
|
84
|
-
this._ensureOutputsTop();
|
|
85
|
-
if (index >= this._outputCollection.length) {
|
|
86
|
-
throw ( new Error('Output index out of range!'));
|
|
87
|
-
}
|
|
88
|
-
return this._outputsTop.getPrefixSum(index - 1);
|
|
89
|
-
}
|
|
90
|
-
updateOutputHeight(index, height) {
|
|
91
|
-
if (index >= this._outputCollection.length) {
|
|
92
|
-
throw ( new Error('Output index out of range!'));
|
|
93
|
-
}
|
|
94
|
-
this._ensureOutputsTop();
|
|
95
|
-
this._outputCollection[index] = height;
|
|
96
|
-
if (this._outputsTop.setValue(index, height)) {
|
|
97
|
-
this._onDidChangeOutputLayout.fire();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
getOutputTotalHeight() {
|
|
101
|
-
this._ensureOutputsTop();
|
|
102
|
-
return this._outputsTop?.getTotalSum() ?? 0;
|
|
103
|
-
}
|
|
104
|
-
dispose() {
|
|
105
|
-
super.dispose();
|
|
106
|
-
this._outputViewModels.forEach(output => {
|
|
107
|
-
output.dispose();
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
DiffNestedCellViewModel = ( __decorate([
|
|
112
|
-
( __param(1, INotebookService))
|
|
113
|
-
], DiffNestedCellViewModel));
|
|
114
|
-
|
|
115
|
-
export { DiffNestedCellViewModel };
|