@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,886 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Emitter } from '../../../../../base/common/event.js';
|
|
3
|
-
import { hash } from '../../../../../base/common/hash.js';
|
|
4
|
-
import { Disposable } from '../../../../../base/common/lifecycle.js';
|
|
5
|
-
import { DiffEditorWidget } from '../../../../../editor/browser/widget/diffEditor/diffEditorWidget.js';
|
|
6
|
-
import { getEditorPadding } from './diffCellEditorOptions.js';
|
|
7
|
-
import { DiffNestedCellViewModel } from './diffNestedCellViewModel.js';
|
|
8
|
-
import { NotebookDiffViewEventType } from './eventDispatcher.js';
|
|
9
|
-
import { DIFF_CELL_MARGIN, DiffSide } from './notebookDiffEditorBrowser.js';
|
|
10
|
-
import { CellLayoutState } from '../notebookBrowser.js';
|
|
11
|
-
import { getFormattedMetadataJSON } from '../../common/model/notebookCellTextModel.js';
|
|
12
|
-
import { CellUri } from '../../common/notebookCommon.js';
|
|
13
|
-
import { Schemas } from '../../../../../base/common/network.js';
|
|
14
|
-
import { NotebookDocumentMetadataTextModel } from '../../common/model/notebookMetadataTextModel.js';
|
|
15
|
-
|
|
16
|
-
const PropertyHeaderHeight = 25;
|
|
17
|
-
const HeightOfHiddenLinesRegionInDiffEditor = 24;
|
|
18
|
-
const DefaultLineHeight = 17;
|
|
19
|
-
var PropertyFoldingState;
|
|
20
|
-
(function(PropertyFoldingState) {
|
|
21
|
-
PropertyFoldingState[PropertyFoldingState["Expanded"] = 0] = "Expanded";
|
|
22
|
-
PropertyFoldingState[PropertyFoldingState["Collapsed"] = 1] = "Collapsed";
|
|
23
|
-
})(PropertyFoldingState || (PropertyFoldingState = {}));
|
|
24
|
-
const OUTPUT_EDITOR_HEIGHT_MAGIC = 1440;
|
|
25
|
-
class DiffElementViewModelBase extends Disposable {
|
|
26
|
-
constructor(mainDocumentTextModel, editorEventDispatcher, initData) {
|
|
27
|
-
super();
|
|
28
|
-
this.mainDocumentTextModel = mainDocumentTextModel;
|
|
29
|
-
this.editorEventDispatcher = editorEventDispatcher;
|
|
30
|
-
this.initData = initData;
|
|
31
|
-
this._layoutInfoEmitter = this._register(( new Emitter()));
|
|
32
|
-
this.onDidLayoutChange = this._layoutInfoEmitter.event;
|
|
33
|
-
this._register(
|
|
34
|
-
this.editorEventDispatcher.onDidChangeLayout(e => this._layoutInfoEmitter.fire({
|
|
35
|
-
outerWidth: true
|
|
36
|
-
}))
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
class DiffElementPlaceholderViewModel extends DiffElementViewModelBase {
|
|
41
|
-
constructor(mainDocumentTextModel, editorEventDispatcher, initData) {
|
|
42
|
-
super(mainDocumentTextModel, editorEventDispatcher, initData);
|
|
43
|
-
this.type = "placeholder";
|
|
44
|
-
this.hiddenCells = [];
|
|
45
|
-
this._unfoldHiddenCells = this._register(( new Emitter()));
|
|
46
|
-
this.onUnfoldHiddenCells = this._unfoldHiddenCells.event;
|
|
47
|
-
this.renderOutput = false;
|
|
48
|
-
}
|
|
49
|
-
get totalHeight() {
|
|
50
|
-
return 24 + (2 * DIFF_CELL_MARGIN);
|
|
51
|
-
}
|
|
52
|
-
getHeight(_) {
|
|
53
|
-
return this.totalHeight;
|
|
54
|
-
}
|
|
55
|
-
layoutChange() {}
|
|
56
|
-
showHiddenCells() {
|
|
57
|
-
this._unfoldHiddenCells.fire();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
class NotebookDocumentMetadataViewModel extends DiffElementViewModelBase {
|
|
61
|
-
set editorHeight(height) {
|
|
62
|
-
this._layout({
|
|
63
|
-
editorHeight: height
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
get editorHeight() {
|
|
67
|
-
throw ( new Error("Use Cell.layoutInfo.editorHeight"));
|
|
68
|
-
}
|
|
69
|
-
set editorMargin(margin) {
|
|
70
|
-
this._layout({
|
|
71
|
-
editorMargin: margin
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
get editorMargin() {
|
|
75
|
-
throw ( new Error("Use Cell.layoutInfo.editorMargin"));
|
|
76
|
-
}
|
|
77
|
-
get layoutInfo() {
|
|
78
|
-
return this._layoutInfo;
|
|
79
|
-
}
|
|
80
|
-
get totalHeight() {
|
|
81
|
-
return this.layoutInfo.totalHeight;
|
|
82
|
-
}
|
|
83
|
-
constructor(
|
|
84
|
-
originalDocumentTextModel,
|
|
85
|
-
modifiedDocumentTextModel,
|
|
86
|
-
type,
|
|
87
|
-
editorEventDispatcher,
|
|
88
|
-
initData,
|
|
89
|
-
notebookService,
|
|
90
|
-
editorHeightCalculator
|
|
91
|
-
) {
|
|
92
|
-
super(originalDocumentTextModel, editorEventDispatcher, initData);
|
|
93
|
-
this.originalDocumentTextModel = originalDocumentTextModel;
|
|
94
|
-
this.modifiedDocumentTextModel = modifiedDocumentTextModel;
|
|
95
|
-
this.type = type;
|
|
96
|
-
this.editorHeightCalculator = editorHeightCalculator;
|
|
97
|
-
this.renderOutput = false;
|
|
98
|
-
this._sourceEditorViewState = null;
|
|
99
|
-
const cellStatusHeight = PropertyHeaderHeight;
|
|
100
|
-
this._layoutInfo = {
|
|
101
|
-
width: 0,
|
|
102
|
-
editorHeight: 0,
|
|
103
|
-
editorMargin: 0,
|
|
104
|
-
metadataHeight: 0,
|
|
105
|
-
cellStatusHeight,
|
|
106
|
-
metadataStatusHeight: 0,
|
|
107
|
-
rawOutputHeight: 0,
|
|
108
|
-
outputTotalHeight: 0,
|
|
109
|
-
outputStatusHeight: 0,
|
|
110
|
-
outputMetadataHeight: 0,
|
|
111
|
-
bodyMargin: 32,
|
|
112
|
-
totalHeight: 82 + cellStatusHeight + 0,
|
|
113
|
-
layoutState: CellLayoutState.Uninitialized
|
|
114
|
-
};
|
|
115
|
-
this.cellFoldingState = type === "modifiedMetadata" ? PropertyFoldingState.Expanded : PropertyFoldingState.Collapsed;
|
|
116
|
-
this.originalMetadata = this._register(( new NotebookDocumentMetadataTextModel(originalDocumentTextModel)));
|
|
117
|
-
this.modifiedMetadata = this._register(( new NotebookDocumentMetadataTextModel(modifiedDocumentTextModel)));
|
|
118
|
-
}
|
|
119
|
-
async computeHeights() {
|
|
120
|
-
if (this.type === "unchangedMetadata") {
|
|
121
|
-
this.editorHeight = this.editorHeightCalculator.computeHeightFromLines(this.originalMetadata.textBuffer.getLineCount());
|
|
122
|
-
} else {
|
|
123
|
-
const original = this.originalMetadata.uri;
|
|
124
|
-
const modified = this.modifiedMetadata.uri;
|
|
125
|
-
this.editorHeight = await this.editorHeightCalculator.diffAndComputeHeight(original, modified);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
layoutChange() {
|
|
129
|
-
this._layout({
|
|
130
|
-
recomputeOutput: true
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
_layout(delta) {
|
|
134
|
-
const width = delta.width !== undefined ? delta.width : this._layoutInfo.width;
|
|
135
|
-
const editorHeight = delta.editorHeight !== undefined ? delta.editorHeight : this._layoutInfo.editorHeight;
|
|
136
|
-
const editorMargin = delta.editorMargin !== undefined ? delta.editorMargin : this._layoutInfo.editorMargin;
|
|
137
|
-
const cellStatusHeight = delta.cellStatusHeight !== undefined ? delta.cellStatusHeight : this._layoutInfo.cellStatusHeight;
|
|
138
|
-
const bodyMargin = delta.bodyMargin !== undefined ? delta.bodyMargin : this._layoutInfo.bodyMargin;
|
|
139
|
-
const totalHeight = editorHeight + editorMargin + cellStatusHeight + bodyMargin;
|
|
140
|
-
const newLayout = {
|
|
141
|
-
width: width,
|
|
142
|
-
editorHeight: editorHeight,
|
|
143
|
-
editorMargin: editorMargin,
|
|
144
|
-
metadataHeight: 0,
|
|
145
|
-
cellStatusHeight,
|
|
146
|
-
metadataStatusHeight: 0,
|
|
147
|
-
outputTotalHeight: 0,
|
|
148
|
-
outputStatusHeight: 0,
|
|
149
|
-
bodyMargin: bodyMargin,
|
|
150
|
-
rawOutputHeight: 0,
|
|
151
|
-
outputMetadataHeight: 0,
|
|
152
|
-
totalHeight: totalHeight,
|
|
153
|
-
layoutState: CellLayoutState.Measured
|
|
154
|
-
};
|
|
155
|
-
let somethingChanged = false;
|
|
156
|
-
const changeEvent = {};
|
|
157
|
-
if (newLayout.width !== this._layoutInfo.width) {
|
|
158
|
-
changeEvent.width = true;
|
|
159
|
-
somethingChanged = true;
|
|
160
|
-
}
|
|
161
|
-
if (newLayout.editorHeight !== this._layoutInfo.editorHeight) {
|
|
162
|
-
changeEvent.editorHeight = true;
|
|
163
|
-
somethingChanged = true;
|
|
164
|
-
}
|
|
165
|
-
if (newLayout.editorMargin !== this._layoutInfo.editorMargin) {
|
|
166
|
-
changeEvent.editorMargin = true;
|
|
167
|
-
somethingChanged = true;
|
|
168
|
-
}
|
|
169
|
-
if (newLayout.cellStatusHeight !== this._layoutInfo.cellStatusHeight) {
|
|
170
|
-
changeEvent.cellStatusHeight = true;
|
|
171
|
-
somethingChanged = true;
|
|
172
|
-
}
|
|
173
|
-
if (newLayout.bodyMargin !== this._layoutInfo.bodyMargin) {
|
|
174
|
-
changeEvent.bodyMargin = true;
|
|
175
|
-
somethingChanged = true;
|
|
176
|
-
}
|
|
177
|
-
if (newLayout.totalHeight !== this._layoutInfo.totalHeight) {
|
|
178
|
-
changeEvent.totalHeight = true;
|
|
179
|
-
somethingChanged = true;
|
|
180
|
-
}
|
|
181
|
-
if (somethingChanged) {
|
|
182
|
-
this._layoutInfo = newLayout;
|
|
183
|
-
this._fireLayoutChangeEvent(changeEvent);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
getHeight(lineHeight) {
|
|
187
|
-
if (this._layoutInfo.layoutState === CellLayoutState.Uninitialized) {
|
|
188
|
-
const editorHeight = this.cellFoldingState === PropertyFoldingState.Collapsed ? 0 : this.computeInputEditorHeight(lineHeight);
|
|
189
|
-
return this._computeTotalHeight(editorHeight);
|
|
190
|
-
} else {
|
|
191
|
-
return this._layoutInfo.totalHeight;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
_computeTotalHeight(editorHeight) {
|
|
195
|
-
const totalHeight = editorHeight + this._layoutInfo.editorMargin + this._layoutInfo.metadataHeight + this._layoutInfo.cellStatusHeight + this._layoutInfo.metadataStatusHeight + this._layoutInfo.outputTotalHeight + this._layoutInfo.outputStatusHeight + this._layoutInfo.outputMetadataHeight + this._layoutInfo.bodyMargin;
|
|
196
|
-
return totalHeight;
|
|
197
|
-
}
|
|
198
|
-
computeInputEditorHeight(_lineHeight) {
|
|
199
|
-
return this.editorHeightCalculator.computeHeightFromLines(Math.max(
|
|
200
|
-
this.originalMetadata.textBuffer.getLineCount(),
|
|
201
|
-
this.modifiedMetadata.textBuffer.getLineCount()
|
|
202
|
-
));
|
|
203
|
-
}
|
|
204
|
-
_fireLayoutChangeEvent(state) {
|
|
205
|
-
this._layoutInfoEmitter.fire(state);
|
|
206
|
-
this.editorEventDispatcher.emit([{
|
|
207
|
-
type: NotebookDiffViewEventType.CellLayoutChanged,
|
|
208
|
-
source: this._layoutInfo
|
|
209
|
-
}]);
|
|
210
|
-
}
|
|
211
|
-
getComputedCellContainerWidth(layoutInfo, diffEditor, fullWidth) {
|
|
212
|
-
if (fullWidth) {
|
|
213
|
-
return layoutInfo.width - 2 * DIFF_CELL_MARGIN + (diffEditor ? DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH : 0) - 2;
|
|
214
|
-
}
|
|
215
|
-
return (layoutInfo.width - 2 * DIFF_CELL_MARGIN + (diffEditor ? DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH : 0)) / 2 - 18 - 2;
|
|
216
|
-
}
|
|
217
|
-
getSourceEditorViewState() {
|
|
218
|
-
return this._sourceEditorViewState;
|
|
219
|
-
}
|
|
220
|
-
saveSpirceEditorViewState(viewState) {
|
|
221
|
-
this._sourceEditorViewState = viewState;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
class DiffElementCellViewModelBase extends DiffElementViewModelBase {
|
|
225
|
-
hideUnchangedCells() {
|
|
226
|
-
this._hideUnchangedCells.fire();
|
|
227
|
-
}
|
|
228
|
-
set rawOutputHeight(height) {
|
|
229
|
-
this._layout({
|
|
230
|
-
rawOutputHeight: Math.min(OUTPUT_EDITOR_HEIGHT_MAGIC, height)
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
get rawOutputHeight() {
|
|
234
|
-
throw ( new Error("Use Cell.layoutInfo.rawOutputHeight"));
|
|
235
|
-
}
|
|
236
|
-
set outputStatusHeight(height) {
|
|
237
|
-
this._layout({
|
|
238
|
-
outputStatusHeight: height
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
get outputStatusHeight() {
|
|
242
|
-
throw ( new Error("Use Cell.layoutInfo.outputStatusHeight"));
|
|
243
|
-
}
|
|
244
|
-
set outputMetadataHeight(height) {
|
|
245
|
-
this._layout({
|
|
246
|
-
outputMetadataHeight: height
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
get outputMetadataHeight() {
|
|
250
|
-
throw ( new Error("Use Cell.layoutInfo.outputStatusHeight"));
|
|
251
|
-
}
|
|
252
|
-
set editorHeight(height) {
|
|
253
|
-
this._layout({
|
|
254
|
-
editorHeight: height
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
get editorHeight() {
|
|
258
|
-
throw ( new Error("Use Cell.layoutInfo.editorHeight"));
|
|
259
|
-
}
|
|
260
|
-
set editorMargin(margin) {
|
|
261
|
-
this._layout({
|
|
262
|
-
editorMargin: margin
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
get editorMargin() {
|
|
266
|
-
throw ( new Error("Use Cell.layoutInfo.editorMargin"));
|
|
267
|
-
}
|
|
268
|
-
set metadataStatusHeight(height) {
|
|
269
|
-
this._layout({
|
|
270
|
-
metadataStatusHeight: height
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
get metadataStatusHeight() {
|
|
274
|
-
throw ( new Error("Use Cell.layoutInfo.outputStatusHeight"));
|
|
275
|
-
}
|
|
276
|
-
set metadataHeight(height) {
|
|
277
|
-
this._layout({
|
|
278
|
-
metadataHeight: height
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
get metadataHeight() {
|
|
282
|
-
throw ( new Error("Use Cell.layoutInfo.metadataHeight"));
|
|
283
|
-
}
|
|
284
|
-
set renderOutput(value) {
|
|
285
|
-
this._renderOutput = value;
|
|
286
|
-
this._layout({
|
|
287
|
-
recomputeOutput: true
|
|
288
|
-
});
|
|
289
|
-
this._stateChangeEmitter.fire({
|
|
290
|
-
renderOutput: this._renderOutput
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
get renderOutput() {
|
|
294
|
-
return this._renderOutput;
|
|
295
|
-
}
|
|
296
|
-
get layoutInfo() {
|
|
297
|
-
return this._layoutInfo;
|
|
298
|
-
}
|
|
299
|
-
get totalHeight() {
|
|
300
|
-
return this.layoutInfo.totalHeight;
|
|
301
|
-
}
|
|
302
|
-
get ignoreOutputs() {
|
|
303
|
-
return this.configurationService.getValue("notebook.diff.ignoreOutputs") || !!(this.mainDocumentTextModel?.transientOptions.transientOutputs);
|
|
304
|
-
}
|
|
305
|
-
get ignoreMetadata() {
|
|
306
|
-
return this.configurationService.getValue("notebook.diff.ignoreMetadata");
|
|
307
|
-
}
|
|
308
|
-
constructor(
|
|
309
|
-
mainDocumentTextModel,
|
|
310
|
-
original,
|
|
311
|
-
modified,
|
|
312
|
-
type,
|
|
313
|
-
editorEventDispatcher,
|
|
314
|
-
initData,
|
|
315
|
-
notebookService,
|
|
316
|
-
index,
|
|
317
|
-
configurationService,
|
|
318
|
-
diffEditorHeightCalculator
|
|
319
|
-
) {
|
|
320
|
-
super(mainDocumentTextModel, editorEventDispatcher, initData);
|
|
321
|
-
this.type = type;
|
|
322
|
-
this.index = index;
|
|
323
|
-
this.configurationService = configurationService;
|
|
324
|
-
this.diffEditorHeightCalculator = diffEditorHeightCalculator;
|
|
325
|
-
this._stateChangeEmitter = this._register(( new Emitter()));
|
|
326
|
-
this.onDidStateChange = this._stateChangeEmitter.event;
|
|
327
|
-
this._hideUnchangedCells = this._register(( new Emitter()));
|
|
328
|
-
this.onHideUnchangedCells = this._hideUnchangedCells.event;
|
|
329
|
-
this._renderOutput = true;
|
|
330
|
-
this._sourceEditorViewState = null;
|
|
331
|
-
this._outputEditorViewState = null;
|
|
332
|
-
this._metadataEditorViewState = null;
|
|
333
|
-
this.original = original ? this._register(( new DiffNestedCellViewModel(original, notebookService))) : undefined;
|
|
334
|
-
this.modified = modified ? this._register(( new DiffNestedCellViewModel(modified, notebookService))) : undefined;
|
|
335
|
-
const editorHeight = this._estimateEditorHeight(initData.fontInfo);
|
|
336
|
-
const cellStatusHeight = PropertyHeaderHeight;
|
|
337
|
-
this._layoutInfo = {
|
|
338
|
-
width: 0,
|
|
339
|
-
editorHeight: editorHeight,
|
|
340
|
-
editorMargin: 0,
|
|
341
|
-
metadataHeight: 0,
|
|
342
|
-
cellStatusHeight,
|
|
343
|
-
metadataStatusHeight: this.ignoreMetadata ? 0 : PropertyHeaderHeight,
|
|
344
|
-
rawOutputHeight: 0,
|
|
345
|
-
outputTotalHeight: 0,
|
|
346
|
-
outputStatusHeight: this.ignoreOutputs ? 0 : PropertyHeaderHeight,
|
|
347
|
-
outputMetadataHeight: 0,
|
|
348
|
-
bodyMargin: 32,
|
|
349
|
-
totalHeight: 82 + cellStatusHeight + editorHeight,
|
|
350
|
-
layoutState: CellLayoutState.Uninitialized
|
|
351
|
-
};
|
|
352
|
-
this.cellFoldingState = modified?.getTextBufferHash() !== original?.getTextBufferHash() ? PropertyFoldingState.Expanded : PropertyFoldingState.Collapsed;
|
|
353
|
-
this.metadataFoldingState = PropertyFoldingState.Collapsed;
|
|
354
|
-
this.outputFoldingState = PropertyFoldingState.Collapsed;
|
|
355
|
-
}
|
|
356
|
-
layoutChange() {
|
|
357
|
-
this._layout({
|
|
358
|
-
recomputeOutput: true
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
_estimateEditorHeight(fontInfo) {
|
|
362
|
-
const lineHeight = fontInfo?.lineHeight ?? 17;
|
|
363
|
-
switch (this.type) {
|
|
364
|
-
case "unchanged":
|
|
365
|
-
case "insert":
|
|
366
|
-
{
|
|
367
|
-
const lineCount = this.modified.textModel.textBuffer.getLineCount();
|
|
368
|
-
const editorHeight = lineCount * lineHeight + getEditorPadding(lineCount).top + getEditorPadding(lineCount).bottom;
|
|
369
|
-
return editorHeight;
|
|
370
|
-
}
|
|
371
|
-
case "delete":
|
|
372
|
-
case "modified":
|
|
373
|
-
{
|
|
374
|
-
const lineCount = this.original.textModel.textBuffer.getLineCount();
|
|
375
|
-
const editorHeight = lineCount * lineHeight + getEditorPadding(lineCount).top + getEditorPadding(lineCount).bottom;
|
|
376
|
-
return editorHeight;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
_layout(delta) {
|
|
381
|
-
const width = delta.width !== undefined ? delta.width : this._layoutInfo.width;
|
|
382
|
-
const editorHeight = delta.editorHeight !== undefined ? delta.editorHeight : this._layoutInfo.editorHeight;
|
|
383
|
-
const editorMargin = delta.editorMargin !== undefined ? delta.editorMargin : this._layoutInfo.editorMargin;
|
|
384
|
-
const metadataHeight = delta.metadataHeight !== undefined ? delta.metadataHeight : this._layoutInfo.metadataHeight;
|
|
385
|
-
const cellStatusHeight = delta.cellStatusHeight !== undefined ? delta.cellStatusHeight : this._layoutInfo.cellStatusHeight;
|
|
386
|
-
const metadataStatusHeight = delta.metadataStatusHeight !== undefined ? delta.metadataStatusHeight : this._layoutInfo.metadataStatusHeight;
|
|
387
|
-
const rawOutputHeight = delta.rawOutputHeight !== undefined ? delta.rawOutputHeight : this._layoutInfo.rawOutputHeight;
|
|
388
|
-
const outputStatusHeight = delta.outputStatusHeight !== undefined ? delta.outputStatusHeight : this._layoutInfo.outputStatusHeight;
|
|
389
|
-
const bodyMargin = delta.bodyMargin !== undefined ? delta.bodyMargin : this._layoutInfo.bodyMargin;
|
|
390
|
-
const outputMetadataHeight = delta.outputMetadataHeight !== undefined ? delta.outputMetadataHeight : this._layoutInfo.outputMetadataHeight;
|
|
391
|
-
const outputHeight = this.ignoreOutputs ? 0 : (delta.recomputeOutput || delta.rawOutputHeight !== undefined || delta.outputMetadataHeight !== undefined) ? this._getOutputTotalHeight(rawOutputHeight, outputMetadataHeight) : this._layoutInfo.outputTotalHeight;
|
|
392
|
-
const totalHeight = editorHeight + editorMargin + cellStatusHeight + metadataHeight + metadataStatusHeight + outputHeight + outputStatusHeight + bodyMargin;
|
|
393
|
-
const newLayout = {
|
|
394
|
-
width: width,
|
|
395
|
-
editorHeight: editorHeight,
|
|
396
|
-
editorMargin: editorMargin,
|
|
397
|
-
metadataHeight: metadataHeight,
|
|
398
|
-
cellStatusHeight,
|
|
399
|
-
metadataStatusHeight: metadataStatusHeight,
|
|
400
|
-
outputTotalHeight: outputHeight,
|
|
401
|
-
outputStatusHeight: outputStatusHeight,
|
|
402
|
-
bodyMargin: bodyMargin,
|
|
403
|
-
rawOutputHeight: rawOutputHeight,
|
|
404
|
-
outputMetadataHeight: outputMetadataHeight,
|
|
405
|
-
totalHeight: totalHeight,
|
|
406
|
-
layoutState: CellLayoutState.Measured
|
|
407
|
-
};
|
|
408
|
-
let somethingChanged = false;
|
|
409
|
-
const changeEvent = {};
|
|
410
|
-
if (newLayout.width !== this._layoutInfo.width) {
|
|
411
|
-
changeEvent.width = true;
|
|
412
|
-
somethingChanged = true;
|
|
413
|
-
}
|
|
414
|
-
if (newLayout.editorHeight !== this._layoutInfo.editorHeight) {
|
|
415
|
-
changeEvent.editorHeight = true;
|
|
416
|
-
somethingChanged = true;
|
|
417
|
-
}
|
|
418
|
-
if (newLayout.editorMargin !== this._layoutInfo.editorMargin) {
|
|
419
|
-
changeEvent.editorMargin = true;
|
|
420
|
-
somethingChanged = true;
|
|
421
|
-
}
|
|
422
|
-
if (newLayout.metadataHeight !== this._layoutInfo.metadataHeight) {
|
|
423
|
-
changeEvent.metadataHeight = true;
|
|
424
|
-
somethingChanged = true;
|
|
425
|
-
}
|
|
426
|
-
if (newLayout.cellStatusHeight !== this._layoutInfo.cellStatusHeight) {
|
|
427
|
-
changeEvent.cellStatusHeight = true;
|
|
428
|
-
somethingChanged = true;
|
|
429
|
-
}
|
|
430
|
-
if (newLayout.metadataStatusHeight !== this._layoutInfo.metadataStatusHeight) {
|
|
431
|
-
changeEvent.metadataStatusHeight = true;
|
|
432
|
-
somethingChanged = true;
|
|
433
|
-
}
|
|
434
|
-
if (newLayout.outputTotalHeight !== this._layoutInfo.outputTotalHeight) {
|
|
435
|
-
changeEvent.outputTotalHeight = true;
|
|
436
|
-
somethingChanged = true;
|
|
437
|
-
}
|
|
438
|
-
if (newLayout.outputStatusHeight !== this._layoutInfo.outputStatusHeight) {
|
|
439
|
-
changeEvent.outputStatusHeight = true;
|
|
440
|
-
somethingChanged = true;
|
|
441
|
-
}
|
|
442
|
-
if (newLayout.bodyMargin !== this._layoutInfo.bodyMargin) {
|
|
443
|
-
changeEvent.bodyMargin = true;
|
|
444
|
-
somethingChanged = true;
|
|
445
|
-
}
|
|
446
|
-
if (newLayout.outputMetadataHeight !== this._layoutInfo.outputMetadataHeight) {
|
|
447
|
-
changeEvent.outputMetadataHeight = true;
|
|
448
|
-
somethingChanged = true;
|
|
449
|
-
}
|
|
450
|
-
if (newLayout.totalHeight !== this._layoutInfo.totalHeight) {
|
|
451
|
-
changeEvent.totalHeight = true;
|
|
452
|
-
somethingChanged = true;
|
|
453
|
-
}
|
|
454
|
-
if (somethingChanged) {
|
|
455
|
-
this._layoutInfo = newLayout;
|
|
456
|
-
this._fireLayoutChangeEvent(changeEvent);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
getHeight(lineHeight) {
|
|
460
|
-
if (this._layoutInfo.layoutState === CellLayoutState.Uninitialized) {
|
|
461
|
-
const editorHeight = this.cellFoldingState === PropertyFoldingState.Collapsed ? 0 : this.computeInputEditorHeight(lineHeight);
|
|
462
|
-
return this._computeTotalHeight(editorHeight);
|
|
463
|
-
} else {
|
|
464
|
-
return this._layoutInfo.totalHeight;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
_computeTotalHeight(editorHeight) {
|
|
468
|
-
const totalHeight = editorHeight + this._layoutInfo.editorMargin + this._layoutInfo.metadataHeight + this._layoutInfo.cellStatusHeight + this._layoutInfo.metadataStatusHeight + this._layoutInfo.outputTotalHeight + this._layoutInfo.outputStatusHeight + this._layoutInfo.outputMetadataHeight + this._layoutInfo.bodyMargin;
|
|
469
|
-
return totalHeight;
|
|
470
|
-
}
|
|
471
|
-
computeInputEditorHeight(lineHeight) {
|
|
472
|
-
const lineCount = Math.max(
|
|
473
|
-
this.original?.textModel.textBuffer.getLineCount() ?? 1,
|
|
474
|
-
this.modified?.textModel.textBuffer.getLineCount() ?? 1
|
|
475
|
-
);
|
|
476
|
-
return this.diffEditorHeightCalculator.computeHeightFromLines(lineCount);
|
|
477
|
-
}
|
|
478
|
-
_getOutputTotalHeight(rawOutputHeight, metadataHeight) {
|
|
479
|
-
if (this.outputFoldingState === PropertyFoldingState.Collapsed) {
|
|
480
|
-
return 0;
|
|
481
|
-
}
|
|
482
|
-
if (this.renderOutput) {
|
|
483
|
-
if (this.isOutputEmpty()) {
|
|
484
|
-
return 24;
|
|
485
|
-
}
|
|
486
|
-
return this.getRichOutputTotalHeight() + metadataHeight;
|
|
487
|
-
} else {
|
|
488
|
-
return rawOutputHeight;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
_fireLayoutChangeEvent(state) {
|
|
492
|
-
this._layoutInfoEmitter.fire(state);
|
|
493
|
-
this.editorEventDispatcher.emit([{
|
|
494
|
-
type: NotebookDiffViewEventType.CellLayoutChanged,
|
|
495
|
-
source: this._layoutInfo
|
|
496
|
-
}]);
|
|
497
|
-
}
|
|
498
|
-
getComputedCellContainerWidth(layoutInfo, diffEditor, fullWidth) {
|
|
499
|
-
if (fullWidth) {
|
|
500
|
-
return layoutInfo.width - 2 * DIFF_CELL_MARGIN + (diffEditor ? DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH : 0) - 2;
|
|
501
|
-
}
|
|
502
|
-
return (layoutInfo.width - 2 * DIFF_CELL_MARGIN + (diffEditor ? DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH : 0)) / 2 - 18 - 2;
|
|
503
|
-
}
|
|
504
|
-
getOutputEditorViewState() {
|
|
505
|
-
return this._outputEditorViewState;
|
|
506
|
-
}
|
|
507
|
-
saveOutputEditorViewState(viewState) {
|
|
508
|
-
this._outputEditorViewState = viewState;
|
|
509
|
-
}
|
|
510
|
-
getMetadataEditorViewState() {
|
|
511
|
-
return this._metadataEditorViewState;
|
|
512
|
-
}
|
|
513
|
-
saveMetadataEditorViewState(viewState) {
|
|
514
|
-
this._metadataEditorViewState = viewState;
|
|
515
|
-
}
|
|
516
|
-
getSourceEditorViewState() {
|
|
517
|
-
return this._sourceEditorViewState;
|
|
518
|
-
}
|
|
519
|
-
saveSpirceEditorViewState(viewState) {
|
|
520
|
-
this._sourceEditorViewState = viewState;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
class SideBySideDiffElementViewModel extends DiffElementCellViewModelBase {
|
|
524
|
-
get originalDocument() {
|
|
525
|
-
return this.otherDocumentTextModel;
|
|
526
|
-
}
|
|
527
|
-
get modifiedDocument() {
|
|
528
|
-
return this.mainDocumentTextModel;
|
|
529
|
-
}
|
|
530
|
-
constructor(
|
|
531
|
-
mainDocumentTextModel,
|
|
532
|
-
otherDocumentTextModel,
|
|
533
|
-
original,
|
|
534
|
-
modified,
|
|
535
|
-
type,
|
|
536
|
-
editorEventDispatcher,
|
|
537
|
-
initData,
|
|
538
|
-
notebookService,
|
|
539
|
-
configurationService,
|
|
540
|
-
index,
|
|
541
|
-
diffEditorHeightCalculator
|
|
542
|
-
) {
|
|
543
|
-
super(
|
|
544
|
-
mainDocumentTextModel,
|
|
545
|
-
original,
|
|
546
|
-
modified,
|
|
547
|
-
type,
|
|
548
|
-
editorEventDispatcher,
|
|
549
|
-
initData,
|
|
550
|
-
notebookService,
|
|
551
|
-
index,
|
|
552
|
-
configurationService,
|
|
553
|
-
diffEditorHeightCalculator
|
|
554
|
-
);
|
|
555
|
-
this.otherDocumentTextModel = otherDocumentTextModel;
|
|
556
|
-
this.type = type;
|
|
557
|
-
this.cellFoldingState = this.modified.textModel.getValue() !== this.original.textModel.getValue() ? PropertyFoldingState.Expanded : PropertyFoldingState.Collapsed;
|
|
558
|
-
this.metadataFoldingState = PropertyFoldingState.Collapsed;
|
|
559
|
-
this.outputFoldingState = PropertyFoldingState.Collapsed;
|
|
560
|
-
if (this.checkMetadataIfModified()) {
|
|
561
|
-
this.metadataFoldingState = PropertyFoldingState.Expanded;
|
|
562
|
-
}
|
|
563
|
-
if (this.checkIfOutputsModified()) {
|
|
564
|
-
this.outputFoldingState = PropertyFoldingState.Expanded;
|
|
565
|
-
}
|
|
566
|
-
this._register(this.original.onDidChangeOutputLayout(() => {
|
|
567
|
-
this._layout({
|
|
568
|
-
recomputeOutput: true
|
|
569
|
-
});
|
|
570
|
-
}));
|
|
571
|
-
this._register(this.modified.onDidChangeOutputLayout(() => {
|
|
572
|
-
this._layout({
|
|
573
|
-
recomputeOutput: true
|
|
574
|
-
});
|
|
575
|
-
}));
|
|
576
|
-
this._register(this.modified.textModel.onDidChangeContent(() => {
|
|
577
|
-
if (mainDocumentTextModel.transientOptions.cellContentMetadata) {
|
|
578
|
-
const cellMetadataKeys = [...( Object.keys(mainDocumentTextModel.transientOptions.cellContentMetadata))];
|
|
579
|
-
const modifiedMedataRaw = Object.assign({}, this.modified.metadata);
|
|
580
|
-
const originalCellMetadata = this.original.metadata;
|
|
581
|
-
for (const key of cellMetadataKeys) {
|
|
582
|
-
if (Object.hasOwn(originalCellMetadata, key)) {
|
|
583
|
-
modifiedMedataRaw[key] = originalCellMetadata[key];
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
this.modified.textModel.metadata = modifiedMedataRaw;
|
|
587
|
-
}
|
|
588
|
-
}));
|
|
589
|
-
}
|
|
590
|
-
checkIfInputModified() {
|
|
591
|
-
if (this.original.textModel.getTextBufferHash() === this.modified.textModel.getTextBufferHash()) {
|
|
592
|
-
return false;
|
|
593
|
-
}
|
|
594
|
-
return {
|
|
595
|
-
reason: "Cell content has changed"
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
checkIfOutputsModified() {
|
|
599
|
-
if (this.mainDocumentTextModel.transientOptions.transientOutputs || this.ignoreOutputs) {
|
|
600
|
-
return false;
|
|
601
|
-
}
|
|
602
|
-
const ret = outputsEqual(this.original?.outputs ?? [], this.modified?.outputs ?? []);
|
|
603
|
-
if (ret === OutputComparison.Unchanged) {
|
|
604
|
-
return false;
|
|
605
|
-
}
|
|
606
|
-
return {
|
|
607
|
-
reason: ret === OutputComparison.Metadata ? "Output metadata has changed" : undefined,
|
|
608
|
-
kind: ret
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
checkMetadataIfModified() {
|
|
612
|
-
if (this.ignoreMetadata) {
|
|
613
|
-
return false;
|
|
614
|
-
}
|
|
615
|
-
const modified = hash(getFormattedMetadataJSON(
|
|
616
|
-
this.mainDocumentTextModel.transientOptions.transientCellMetadata,
|
|
617
|
-
this.original?.metadata || {},
|
|
618
|
-
this.original?.language
|
|
619
|
-
)) !== hash(getFormattedMetadataJSON(
|
|
620
|
-
this.mainDocumentTextModel.transientOptions.transientCellMetadata,
|
|
621
|
-
this.modified?.metadata ?? {},
|
|
622
|
-
this.modified?.language
|
|
623
|
-
));
|
|
624
|
-
if (modified) {
|
|
625
|
-
return {
|
|
626
|
-
reason: undefined
|
|
627
|
-
};
|
|
628
|
-
} else {
|
|
629
|
-
return false;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
updateOutputHeight(diffSide, index, height) {
|
|
633
|
-
if (diffSide === DiffSide.Original) {
|
|
634
|
-
this.original.updateOutputHeight(index, height);
|
|
635
|
-
} else {
|
|
636
|
-
this.modified.updateOutputHeight(index, height);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
getOutputOffsetInContainer(diffSide, index) {
|
|
640
|
-
if (diffSide === DiffSide.Original) {
|
|
641
|
-
return this.original.getOutputOffset(index);
|
|
642
|
-
} else {
|
|
643
|
-
return this.modified.getOutputOffset(index);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
getOutputOffsetInCell(diffSide, index) {
|
|
647
|
-
const offsetInOutputsContainer = this.getOutputOffsetInContainer(diffSide, index);
|
|
648
|
-
return this._layoutInfo.editorHeight + this._layoutInfo.editorMargin + this._layoutInfo.metadataHeight + this._layoutInfo.cellStatusHeight + this._layoutInfo.metadataStatusHeight + this._layoutInfo.outputStatusHeight + this._layoutInfo.bodyMargin / 2 + offsetInOutputsContainer;
|
|
649
|
-
}
|
|
650
|
-
isOutputEmpty() {
|
|
651
|
-
if (this.mainDocumentTextModel.transientOptions.transientOutputs) {
|
|
652
|
-
return true;
|
|
653
|
-
}
|
|
654
|
-
if (this.checkIfOutputsModified()) {
|
|
655
|
-
return false;
|
|
656
|
-
}
|
|
657
|
-
return (this.original?.outputs || []).length === 0;
|
|
658
|
-
}
|
|
659
|
-
getRichOutputTotalHeight() {
|
|
660
|
-
return Math.max(this.original.getOutputTotalHeight(), this.modified.getOutputTotalHeight());
|
|
661
|
-
}
|
|
662
|
-
getNestedCellViewModel(diffSide) {
|
|
663
|
-
return diffSide === DiffSide.Original ? this.original : this.modified;
|
|
664
|
-
}
|
|
665
|
-
getCellByUri(cellUri) {
|
|
666
|
-
if (( cellUri.toString()) === ( this.original.uri.toString())) {
|
|
667
|
-
return this.original;
|
|
668
|
-
} else {
|
|
669
|
-
return this.modified;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
computeInputEditorHeight(lineHeight) {
|
|
673
|
-
if (this.type === "modified" && typeof this.editorHeightWithUnchangedLinesCollapsed === "number" && this.checkIfInputModified()) {
|
|
674
|
-
return this.editorHeightWithUnchangedLinesCollapsed;
|
|
675
|
-
}
|
|
676
|
-
return super.computeInputEditorHeight(lineHeight);
|
|
677
|
-
}
|
|
678
|
-
async computeModifiedInputEditorHeight() {
|
|
679
|
-
if (this.checkIfInputModified()) {
|
|
680
|
-
this.editorHeightWithUnchangedLinesCollapsed = this._layoutInfo.editorHeight = await this.diffEditorHeightCalculator.diffAndComputeHeight(this.original.uri, this.modified.uri);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
async computeModifiedMetadataEditorHeight() {
|
|
684
|
-
if (this.checkMetadataIfModified()) {
|
|
685
|
-
const originalMetadataUri = CellUri.generateCellPropertyUri(
|
|
686
|
-
this.originalDocument.uri,
|
|
687
|
-
this.original.handle,
|
|
688
|
-
Schemas.vscodeNotebookCellMetadata
|
|
689
|
-
);
|
|
690
|
-
const modifiedMetadataUri = CellUri.generateCellPropertyUri(
|
|
691
|
-
this.modifiedDocument.uri,
|
|
692
|
-
this.modified.handle,
|
|
693
|
-
Schemas.vscodeNotebookCellMetadata
|
|
694
|
-
);
|
|
695
|
-
this._layoutInfo.metadataHeight = await this.diffEditorHeightCalculator.diffAndComputeHeight(originalMetadataUri, modifiedMetadataUri);
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
async computeEditorHeights() {
|
|
699
|
-
if (this.type === "unchanged") {
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
await Promise.all([
|
|
703
|
-
this.computeModifiedInputEditorHeight(),
|
|
704
|
-
this.computeModifiedMetadataEditorHeight()
|
|
705
|
-
]);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
class SingleSideDiffElementViewModel extends DiffElementCellViewModelBase {
|
|
709
|
-
get cellViewModel() {
|
|
710
|
-
return this.type === "insert" ? this.modified : this.original;
|
|
711
|
-
}
|
|
712
|
-
get originalDocument() {
|
|
713
|
-
if (this.type === "insert") {
|
|
714
|
-
return this.otherDocumentTextModel;
|
|
715
|
-
} else {
|
|
716
|
-
return this.mainDocumentTextModel;
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
get modifiedDocument() {
|
|
720
|
-
if (this.type === "insert") {
|
|
721
|
-
return this.mainDocumentTextModel;
|
|
722
|
-
} else {
|
|
723
|
-
return this.otherDocumentTextModel;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
constructor(
|
|
727
|
-
mainDocumentTextModel,
|
|
728
|
-
otherDocumentTextModel,
|
|
729
|
-
original,
|
|
730
|
-
modified,
|
|
731
|
-
type,
|
|
732
|
-
editorEventDispatcher,
|
|
733
|
-
initData,
|
|
734
|
-
notebookService,
|
|
735
|
-
configurationService,
|
|
736
|
-
diffEditorHeightCalculator,
|
|
737
|
-
index
|
|
738
|
-
) {
|
|
739
|
-
super(
|
|
740
|
-
mainDocumentTextModel,
|
|
741
|
-
original,
|
|
742
|
-
modified,
|
|
743
|
-
type,
|
|
744
|
-
editorEventDispatcher,
|
|
745
|
-
initData,
|
|
746
|
-
notebookService,
|
|
747
|
-
index,
|
|
748
|
-
configurationService,
|
|
749
|
-
diffEditorHeightCalculator
|
|
750
|
-
);
|
|
751
|
-
this.otherDocumentTextModel = otherDocumentTextModel;
|
|
752
|
-
this.type = type;
|
|
753
|
-
this._register(this.cellViewModel.onDidChangeOutputLayout(() => {
|
|
754
|
-
this._layout({
|
|
755
|
-
recomputeOutput: true
|
|
756
|
-
});
|
|
757
|
-
}));
|
|
758
|
-
}
|
|
759
|
-
checkIfInputModified() {
|
|
760
|
-
return {
|
|
761
|
-
reason: "Cell content has changed"
|
|
762
|
-
};
|
|
763
|
-
}
|
|
764
|
-
getNestedCellViewModel(diffSide) {
|
|
765
|
-
return this.type === "insert" ? this.modified : this.original;
|
|
766
|
-
}
|
|
767
|
-
checkIfOutputsModified() {
|
|
768
|
-
return false;
|
|
769
|
-
}
|
|
770
|
-
checkMetadataIfModified() {
|
|
771
|
-
return false;
|
|
772
|
-
}
|
|
773
|
-
updateOutputHeight(diffSide, index, height) {
|
|
774
|
-
this.cellViewModel?.updateOutputHeight(index, height);
|
|
775
|
-
}
|
|
776
|
-
getOutputOffsetInContainer(diffSide, index) {
|
|
777
|
-
return this.cellViewModel.getOutputOffset(index);
|
|
778
|
-
}
|
|
779
|
-
getOutputOffsetInCell(diffSide, index) {
|
|
780
|
-
const offsetInOutputsContainer = this.cellViewModel.getOutputOffset(index);
|
|
781
|
-
return this._layoutInfo.editorHeight + this._layoutInfo.editorMargin + this._layoutInfo.metadataHeight + this._layoutInfo.cellStatusHeight + this._layoutInfo.metadataStatusHeight + this._layoutInfo.outputStatusHeight + this._layoutInfo.bodyMargin / 2 + offsetInOutputsContainer;
|
|
782
|
-
}
|
|
783
|
-
isOutputEmpty() {
|
|
784
|
-
if (this.mainDocumentTextModel.transientOptions.transientOutputs) {
|
|
785
|
-
return true;
|
|
786
|
-
}
|
|
787
|
-
return (this.original?.outputs || this.modified?.outputs || []).length === 0;
|
|
788
|
-
}
|
|
789
|
-
getRichOutputTotalHeight() {
|
|
790
|
-
return this.cellViewModel?.getOutputTotalHeight() ?? 0;
|
|
791
|
-
}
|
|
792
|
-
getCellByUri(cellUri) {
|
|
793
|
-
return this.cellViewModel;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
var OutputComparison;
|
|
797
|
-
(function(OutputComparison) {
|
|
798
|
-
OutputComparison[OutputComparison["Unchanged"] = 0] = "Unchanged";
|
|
799
|
-
OutputComparison[OutputComparison["Metadata"] = 1] = "Metadata";
|
|
800
|
-
OutputComparison[OutputComparison["Other"] = 2] = "Other";
|
|
801
|
-
})(OutputComparison || (OutputComparison = {}));
|
|
802
|
-
function outputEqual(a, b) {
|
|
803
|
-
if (hash(a.metadata) === hash(b.metadata)) {
|
|
804
|
-
return OutputComparison.Other;
|
|
805
|
-
}
|
|
806
|
-
for (let j = 0; j < a.outputs.length; j++) {
|
|
807
|
-
const aOutputItem = a.outputs[j];
|
|
808
|
-
const bOutputItem = b.outputs[j];
|
|
809
|
-
if (aOutputItem.mime !== bOutputItem.mime) {
|
|
810
|
-
return OutputComparison.Other;
|
|
811
|
-
}
|
|
812
|
-
if (aOutputItem.data.buffer.length !== bOutputItem.data.buffer.length) {
|
|
813
|
-
return OutputComparison.Other;
|
|
814
|
-
}
|
|
815
|
-
for (let k = 0; k < aOutputItem.data.buffer.length; k++) {
|
|
816
|
-
if (aOutputItem.data.buffer[k] !== bOutputItem.data.buffer[k]) {
|
|
817
|
-
return OutputComparison.Other;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
return OutputComparison.Metadata;
|
|
822
|
-
}
|
|
823
|
-
function outputsEqual(original, modified) {
|
|
824
|
-
if (original.length !== modified.length) {
|
|
825
|
-
return OutputComparison.Other;
|
|
826
|
-
}
|
|
827
|
-
const len = original.length;
|
|
828
|
-
for (let i = 0; i < len; i++) {
|
|
829
|
-
const a = original[i];
|
|
830
|
-
const b = modified[i];
|
|
831
|
-
if (hash(a.metadata) !== hash(b.metadata)) {
|
|
832
|
-
return OutputComparison.Metadata;
|
|
833
|
-
}
|
|
834
|
-
if (a.outputs.length !== b.outputs.length) {
|
|
835
|
-
return OutputComparison.Other;
|
|
836
|
-
}
|
|
837
|
-
for (let j = 0; j < a.outputs.length; j++) {
|
|
838
|
-
const aOutputItem = a.outputs[j];
|
|
839
|
-
const bOutputItem = b.outputs[j];
|
|
840
|
-
if (aOutputItem.mime !== bOutputItem.mime) {
|
|
841
|
-
return OutputComparison.Other;
|
|
842
|
-
}
|
|
843
|
-
if (aOutputItem.data.buffer.length !== bOutputItem.data.buffer.length) {
|
|
844
|
-
return OutputComparison.Other;
|
|
845
|
-
}
|
|
846
|
-
for (let k = 0; k < aOutputItem.data.buffer.length; k++) {
|
|
847
|
-
if (aOutputItem.data.buffer[k] !== bOutputItem.data.buffer[k]) {
|
|
848
|
-
return OutputComparison.Other;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
return OutputComparison.Unchanged;
|
|
854
|
-
}
|
|
855
|
-
function getStreamOutputData(outputs) {
|
|
856
|
-
if (!outputs.length) {
|
|
857
|
-
return null;
|
|
858
|
-
}
|
|
859
|
-
const first = outputs[0];
|
|
860
|
-
const mime = first.mime;
|
|
861
|
-
const sameStream = !outputs.find(op => op.mime !== mime);
|
|
862
|
-
if (sameStream) {
|
|
863
|
-
return ( outputs.map(opit => ( opit.data.toString()))).join("");
|
|
864
|
-
} else {
|
|
865
|
-
return null;
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
function getFormattedOutputJSON(outputs) {
|
|
869
|
-
if (outputs.length === 1) {
|
|
870
|
-
const streamOutputData = getStreamOutputData(outputs[0].outputs);
|
|
871
|
-
if (streamOutputData) {
|
|
872
|
-
return streamOutputData;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
return JSON.stringify(( outputs.map(output => {
|
|
876
|
-
return ({
|
|
877
|
-
metadata: output.metadata,
|
|
878
|
-
outputItems: ( output.outputs.map(opit => ({
|
|
879
|
-
mimeType: opit.mime,
|
|
880
|
-
data: ( opit.data.toString())
|
|
881
|
-
})))
|
|
882
|
-
});
|
|
883
|
-
})), undefined, "\t");
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
export { DefaultLineHeight, DiffElementCellViewModelBase, DiffElementPlaceholderViewModel, DiffElementViewModelBase, HeightOfHiddenLinesRegionInDiffEditor, NotebookDocumentMetadataViewModel, OUTPUT_EDITOR_HEIGHT_MAGIC, OutputComparison, PropertyFoldingState, SideBySideDiffElementViewModel, SingleSideDiffElementViewModel, getFormattedOutputJSON, getStreamOutputData, outputEqual };
|