@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.
Files changed (52) hide show
  1. package/package.json +9 -9
  2. package/services.js +3 -3
  3. package/vscode/src/vs/platform/product/common/product.js +1 -1
  4. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.d.ts +0 -26
  5. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +0 -746
  6. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.d.ts +0 -13
  7. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -300
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.d.ts +0 -8
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -55
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.d.ts +0 -273
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1963
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.d.ts +0 -50
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -314
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.d.ts +0 -258
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -886
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.d.ts +0 -41
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -118
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.d.ts +0 -17
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.js +0 -71
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.d.ts +0 -27
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -40
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.d.ts +0 -23
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.js +0 -313
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.d.ts +0 -51
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.js +0 -265
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.d.ts +0 -24
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.js +0 -185
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.d.ts +0 -28
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.js +0 -104
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.d.ts +0 -10
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.js +0 -43
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.d.ts +0 -21
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.js +0 -41
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.d.ts +0 -25
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.js +0 -69
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css +0 -469
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.d.ts +0 -149
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -933
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.d.ts +0 -180
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -32
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.d.ts +0 -102
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -643
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.d.ts +0 -30
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -197
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.d.ts +0 -75
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.js +0 -539
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.d.ts +0 -13
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.js +0 -39
  49. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.d.ts +0 -19
  50. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.js +0 -90
  51. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.d.ts +0 -26
  52. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.js +0 -92
@@ -1,933 +0,0 @@
1
-
2
- import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
3
- import { localize } from '../../../../../nls.js';
4
- import { $ as $$1, append, createElement, addStandardDisposableGenericMouseDownListener, addStandardDisposableGenericMouseUpListener, scheduleAtNextAnimationFrame } from '../../../../../base/browser/dom.js';
5
- import { IStorageService } from '../../../../../platform/storage/common/storage.service.js';
6
- import { ITelemetryService } from '../../../../../platform/telemetry/common/telemetry.service.js';
7
- import { registerThemingParticipant } from '../../../../../platform/theme/common/themeService.js';
8
- import { IThemeService } from '../../../../../platform/theme/common/themeService.service.js';
9
- import { EditorPaneSelectionCompareResult, EditorPaneSelectionChangeReason } from '../../../../common/editor.js';
10
- import { getDefaultNotebookCreationOptions } from '../notebookEditorWidget.js';
11
- import { CancellationTokenSource } from '../../../../../base/common/cancellation.js';
12
- import { SideBySideDiffElementViewModel } from './diffElementViewModel.js';
13
- import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
14
- import { CellDiffSingleSideRenderer, CellDiffSideBySideRenderer, CellDiffPlaceholderRenderer, NotebookDocumentMetadataDiffRenderer, NotebookTextDiffList, NotebookCellTextDiffListDelegate } from './notebookDiffList.js';
15
- import { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.service.js';
16
- import '../../../../../platform/theme/common/colorUtils.js';
17
- import { foreground, focusBorder } from '../../../../../platform/theme/common/colors/baseColors.js';
18
- import '../../../../../platform/theme/common/colors/chartsColors.js';
19
- import { editorBackground, diffDiagonalFill } from '../../../../../platform/theme/common/colors/editorColors.js';
20
- import '../../../../../platform/theme/common/colors/inputColors.js';
21
- import '../../../../../platform/theme/common/colors/listColors.js';
22
- import '../../../../../platform/theme/common/colors/menuColors.js';
23
- import '../../../../../platform/theme/common/colors/minimapColors.js';
24
- import '../../../../../platform/theme/common/colors/miscColors.js';
25
- import '../../../../../platform/theme/common/colors/quickpickColors.js';
26
- import '../../../../../platform/theme/common/colors/searchColors.js';
27
- import { INotebookEditorWorkerService } from '../../common/services/notebookWorkerService.service.js';
28
- import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.service.js';
29
- import { createBareFontInfoFromRawSettings } from '../../../../../editor/common/config/fontInfoFromSettings.js';
30
- import { PixelRatio } from '../../../../../base/browser/pixelRatio.js';
31
- import { DiffSide, DIFF_CELL_MARGIN } from './notebookDiffEditorBrowser.js';
32
- import { Emitter, Event } from '../../../../../base/common/event.js';
33
- import { DisposableStore, toDisposable } from '../../../../../base/common/lifecycle.js';
34
- import { EditorPane } from '../../../../browser/parts/editor/editorPane.js';
35
- import { NOTEBOOK_DIFF_EDITOR_ID, NotebookSetting, CellUri } from '../../common/notebookCommon.js';
36
- import { SequencerByKey } from '../../../../../base/common/async.js';
37
- import { generateUuid } from '../../../../../base/common/uuid.js';
38
- import { BackLayerWebView } from '../view/renderers/backLayerWebView.js';
39
- import { NotebookDiffEditorEventDispatcher, NotebookDiffLayoutChangedEvent } from './eventDispatcher.js';
40
- import { FontMeasurements } from '../../../../../editor/browser/config/fontMeasurements.js';
41
- import { NotebookOptions } from '../notebookOptions.js';
42
- import { cellIndexesToRanges, cellRangesToIndexes } from '../../common/notebookRange.js';
43
- import { NotebookDiffOverviewRuler } from './notebookDiffOverviewRuler.js';
44
- import { registerZIndex, ZIndex } from '../../../../../platform/layout/browser/zIndexRegistry.js';
45
- import { NotebookDiffViewModel } from './notebookDiffViewModel.js';
46
- import { INotebookService } from '../../common/notebookService.service.js';
47
- import { DiffEditorHeightCalculatorService } from './editorHeightCalculator.js';
48
- import { IEditorService } from '../../../../services/editor/common/editorService.service.js';
49
- import { NotebookInlineDiffWidget } from './inlineDiff/notebookInlineDiffWidget.js';
50
- import '../../../../../base/common/observableInternal/index.js';
51
- import { observableValue } from '../../../../../base/common/observableInternal/observables/observableValue.js';
52
-
53
- var NotebookTextDiffEditor_1;
54
- const $ = $$1;
55
- class NotebookDiffEditorSelection {
56
- constructor(selections) {
57
- this.selections = selections;
58
- }
59
- compare(other) {
60
- if (!(other instanceof NotebookDiffEditorSelection)) {
61
- return EditorPaneSelectionCompareResult.DIFFERENT;
62
- }
63
- if (this.selections.length !== other.selections.length) {
64
- return EditorPaneSelectionCompareResult.DIFFERENT;
65
- }
66
- for (let i = 0; i < this.selections.length; i++) {
67
- if (this.selections[i] !== other.selections[i]) {
68
- return EditorPaneSelectionCompareResult.DIFFERENT;
69
- }
70
- }
71
- return EditorPaneSelectionCompareResult.IDENTICAL;
72
- }
73
- restore(options) {
74
- const notebookOptions = {
75
- cellSelections: cellIndexesToRanges(this.selections)
76
- };
77
- Object.assign(notebookOptions, options);
78
- return notebookOptions;
79
- }
80
- }
81
- let NotebookTextDiffEditor = class NotebookTextDiffEditor extends EditorPane {
82
- static {
83
- NotebookTextDiffEditor_1 = this;
84
- }
85
- static {
86
- this.ENTIRE_DIFF_OVERVIEW_WIDTH = 30;
87
- }
88
- static {
89
- this.ID = NOTEBOOK_DIFF_EDITOR_ID;
90
- }
91
- get textModel() {
92
- return this._model?.modified.notebook;
93
- }
94
- get inlineNotebookEditor() {
95
- if (this._inlineView) {
96
- return this.inlineDiffWidget?.editorWidget;
97
- }
98
- return undefined;
99
- }
100
- get notebookOptions() {
101
- return this._notebookOptions;
102
- }
103
- get isDisposed() {
104
- return this._isDisposed;
105
- }
106
- constructor(
107
- group,
108
- instantiationService,
109
- themeService,
110
- contextKeyService,
111
- notebookEditorWorkerService,
112
- configurationService,
113
- telemetryService,
114
- storageService,
115
- notebookService,
116
- editorService
117
- ) {
118
- super(
119
- NotebookTextDiffEditor_1.ID,
120
- group,
121
- telemetryService,
122
- themeService,
123
- storageService
124
- );
125
- this.instantiationService = instantiationService;
126
- this.contextKeyService = contextKeyService;
127
- this.notebookEditorWorkerService = notebookEditorWorkerService;
128
- this.configurationService = configurationService;
129
- this.notebookService = notebookService;
130
- this.editorService = editorService;
131
- this.creationOptions = getDefaultNotebookCreationOptions();
132
- this._dimension = undefined;
133
- this._modifiedWebview = null;
134
- this._originalWebview = null;
135
- this._webviewTransparentCover = null;
136
- this._inlineView = false;
137
- this._onMouseUp = this._register(( new Emitter()));
138
- this.onMouseUp = this._onMouseUp.event;
139
- this._onDidScroll = this._register(( new Emitter()));
140
- this.onDidScroll = this._onDidScroll.event;
141
- this.onDidChangeScroll = this._onDidScroll.event;
142
- this._model = null;
143
- this._modifiedResourceDisposableStore = this._register(( new DisposableStore()));
144
- this._insetModifyQueueByOutputId = ( new SequencerByKey());
145
- this._onDidDynamicOutputRendered = this._register(( new Emitter()));
146
- this.onDidDynamicOutputRendered = this._onDidDynamicOutputRendered.event;
147
- this._localStore = this._register(( new DisposableStore()));
148
- this._onDidChangeSelection = this._register(( new Emitter()));
149
- this.onDidChangeSelection = this._onDidChangeSelection.event;
150
- this._isDisposed = false;
151
- this._currentChangedIndex = observableValue(this, -1);
152
- this.currentChangedIndex = this._currentChangedIndex;
153
- this.pendingLayouts = ( new WeakMap());
154
- this.diffEditorCalcuator = this.instantiationService.createInstance(DiffEditorHeightCalculatorService, this.fontInfo.lineHeight);
155
- this._notebookOptions = instantiationService.createInstance(NotebookOptions, this.window, false, undefined);
156
- this._register(this._notebookOptions);
157
- this._revealFirst = true;
158
- }
159
- get fontInfo() {
160
- if (!this._fontInfo) {
161
- this._fontInfo = this.createFontInfo();
162
- }
163
- return this._fontInfo;
164
- }
165
- createFontInfo() {
166
- const editorOptions = this.configurationService.getValue("editor");
167
- return FontMeasurements.readFontInfo(
168
- this.window,
169
- createBareFontInfoFromRawSettings(editorOptions, PixelRatio.getInstance(this.window).value)
170
- );
171
- }
172
- isOverviewRulerEnabled() {
173
- return this.configurationService.getValue(NotebookSetting.diffOverviewRuler) ?? false;
174
- }
175
- getSelection() {
176
- const selections = this._list.getFocus();
177
- return ( new NotebookDiffEditorSelection(selections));
178
- }
179
- toggleNotebookCellSelection(cell) {}
180
- updatePerformanceMetadata(cellId, executionId, duration, rendererId) {}
181
- async focusNotebookCell(cell, focus) {}
182
- async focusNextNotebookCell(cell, focus) {}
183
- didFocusOutputInputChange(inputFocused) {}
184
- getScrollTop() {
185
- return this._list?.scrollTop ?? 0;
186
- }
187
- getScrollHeight() {
188
- return this._list?.scrollHeight ?? 0;
189
- }
190
- getScrollPosition() {
191
- return {
192
- scrollTop: this.getScrollTop(),
193
- scrollLeft: this._list?.scrollLeft ?? 0
194
- };
195
- }
196
- setScrollPosition(scrollPosition) {
197
- if (!this._list) {
198
- return;
199
- }
200
- this._list.scrollTop = scrollPosition.scrollTop;
201
- if (scrollPosition.scrollLeft !== undefined) {
202
- this._list.scrollLeft = scrollPosition.scrollLeft;
203
- }
204
- }
205
- delegateVerticalScrollbarPointerDown(browserEvent) {
206
- this._list?.delegateVerticalScrollbarPointerDown(browserEvent);
207
- }
208
- updateOutputHeight(cellInfo, output, outputHeight, isInit) {
209
- const diffElement = cellInfo.diffElement;
210
- const cell = this.getCellByInfo(cellInfo);
211
- const outputIndex = cell.outputsViewModels.indexOf(output);
212
- if (diffElement instanceof SideBySideDiffElementViewModel) {
213
- const info = CellUri.parse(cellInfo.cellUri);
214
- if (!info) {
215
- return;
216
- }
217
- diffElement.updateOutputHeight(( info.notebook.toString()) === this._model?.original.resource.toString() ? DiffSide.Original : DiffSide.Modified, outputIndex, outputHeight);
218
- } else {
219
- diffElement.updateOutputHeight(
220
- diffElement.type === "insert" ? DiffSide.Modified : DiffSide.Original,
221
- outputIndex,
222
- outputHeight
223
- );
224
- }
225
- if (isInit) {
226
- this._onDidDynamicOutputRendered.fire({
227
- cell,
228
- output
229
- });
230
- }
231
- }
232
- setMarkupCellEditState(cellId, editState) {}
233
- didStartDragMarkupCell(cellId, event) {}
234
- didDragMarkupCell(cellId, event) {}
235
- didEndDragMarkupCell(cellId) {}
236
- didDropMarkupCell(cellId) {}
237
- didResizeOutput(cellId) {}
238
- async toggleInlineView() {
239
- this._layoutCancellationTokenSource?.dispose();
240
- this._inlineView = !this._inlineView;
241
- if (!this._lastLayoutProperties) {
242
- return;
243
- }
244
- if (this._inlineView) {
245
- this.layout(
246
- this._lastLayoutProperties?.dimension,
247
- this._lastLayoutProperties?.position
248
- );
249
- this.inlineDiffWidget?.show(
250
- this.input,
251
- this._model?.modified.notebook,
252
- this._model?.original.notebook,
253
- this._options
254
- );
255
- } else {
256
- this.layout(
257
- this._lastLayoutProperties?.dimension,
258
- this._lastLayoutProperties?.position
259
- );
260
- this.inlineDiffWidget?.hide();
261
- }
262
- this._layoutCancellationTokenSource = ( new CancellationTokenSource());
263
- this.updateLayout(this._layoutCancellationTokenSource.token);
264
- }
265
- createEditor(parent) {
266
- this._rootElement = append(parent, $$1(".notebook-text-diff-editor"));
267
- this._overflowContainer = createElement("div");
268
- this._overflowContainer.classList.add("notebook-overflow-widget-container", "monaco-editor");
269
- append(parent, this._overflowContainer);
270
- const renderers = [
271
- this.instantiationService.createInstance(CellDiffSingleSideRenderer, this),
272
- this.instantiationService.createInstance(CellDiffSideBySideRenderer, this),
273
- this.instantiationService.createInstance(CellDiffPlaceholderRenderer, this),
274
- this.instantiationService.createInstance(NotebookDocumentMetadataDiffRenderer, this)
275
- ];
276
- this._listViewContainer = append(this._rootElement, $$1(".notebook-diff-list-view"));
277
- this._list = this.instantiationService.createInstance(
278
- NotebookTextDiffList,
279
- "NotebookTextDiff",
280
- this._listViewContainer,
281
- this.instantiationService.createInstance(NotebookCellTextDiffListDelegate, this.window),
282
- renderers,
283
- this.contextKeyService,
284
- {
285
- setRowLineHeight: false,
286
- setRowHeight: false,
287
- supportDynamicHeights: true,
288
- horizontalScrolling: false,
289
- keyboardSupport: false,
290
- mouseSupport: true,
291
- multipleSelectionSupport: false,
292
- typeNavigationEnabled: true,
293
- paddingBottom: 0,
294
- styleController: _suffix => {
295
- return this._list;
296
- },
297
- overrideStyles: {
298
- listBackground: editorBackground,
299
- listActiveSelectionBackground: editorBackground,
300
- listActiveSelectionForeground: foreground,
301
- listFocusAndSelectionBackground: editorBackground,
302
- listFocusAndSelectionForeground: foreground,
303
- listFocusBackground: editorBackground,
304
- listFocusForeground: foreground,
305
- listHoverForeground: foreground,
306
- listHoverBackground: editorBackground,
307
- listHoverOutline: focusBorder,
308
- listFocusOutline: focusBorder,
309
- listInactiveSelectionBackground: editorBackground,
310
- listInactiveSelectionForeground: foreground,
311
- listInactiveFocusBackground: editorBackground,
312
- listInactiveFocusOutline: editorBackground
313
- },
314
- accessibilityProvider: {
315
- getAriaLabel() {
316
- return null;
317
- },
318
- getWidgetAriaLabel() {
319
- return localize(11819, "Notebook Text Diff");
320
- }
321
- }
322
- }
323
- );
324
- this.inlineDiffWidget = this._register(this.instantiationService.createInstance(
325
- NotebookInlineDiffWidget,
326
- this._rootElement,
327
- this.group.id,
328
- this.window,
329
- this.notebookOptions,
330
- this._dimension
331
- ));
332
- this._register(this._list);
333
- this._register(this._list.onMouseUp(e => {
334
- if (e.element) {
335
- if (typeof e.index === "number") {
336
- this._list.setFocus([e.index]);
337
- }
338
- this._onMouseUp.fire({
339
- event: e.browserEvent,
340
- target: e.element
341
- });
342
- }
343
- }));
344
- this._register(this._list.onDidScroll(() => {
345
- this._onDidScroll.fire();
346
- }));
347
- this._register(this._list.onDidChangeFocus(() => this._onDidChangeSelection.fire({
348
- reason: EditorPaneSelectionChangeReason.USER
349
- })));
350
- this._overviewRulerContainer = createElement("div");
351
- this._overviewRulerContainer.classList.add("notebook-overview-ruler-container");
352
- this._rootElement.appendChild(this._overviewRulerContainer);
353
- this._registerOverviewRuler();
354
- this._webviewTransparentCover = append(this._list.rowsContainer, $(".webview-cover"));
355
- this._webviewTransparentCover.style.display = "none";
356
- this._register(
357
- addStandardDisposableGenericMouseDownListener(this._overflowContainer, e => {
358
- if (e.target.classList.contains("slider") && this._webviewTransparentCover) {
359
- this._webviewTransparentCover.style.display = "block";
360
- }
361
- })
362
- );
363
- this._register(
364
- addStandardDisposableGenericMouseUpListener(this._overflowContainer, () => {
365
- if (this._webviewTransparentCover) {
366
- this._webviewTransparentCover.style.display = "none";
367
- }
368
- })
369
- );
370
- this._register(this._list.onDidScroll(e => {
371
- this._webviewTransparentCover.style.top = `${e.scrollTop}px`;
372
- }));
373
- }
374
- _registerOverviewRuler() {
375
- this._overviewRuler = this._register(this.instantiationService.createInstance(
376
- NotebookDiffOverviewRuler,
377
- this,
378
- NotebookTextDiffEditor_1.ENTIRE_DIFF_OVERVIEW_WIDTH,
379
- this._overviewRulerContainer
380
- ));
381
- }
382
- _updateOutputsOffsetsInWebview(scrollTop, scrollHeight, activeWebview, getActiveNestedCell, diffSide) {
383
- activeWebview.element.style.height = `${scrollHeight}px`;
384
- if (activeWebview.insetMapping) {
385
- const updateItems = [];
386
- const removedItems = [];
387
- activeWebview.insetMapping.forEach((value, key) => {
388
- const cell = getActiveNestedCell(value.cellInfo.diffElement);
389
- if (!cell) {
390
- return;
391
- }
392
- const viewIndex = this._list.indexOf(value.cellInfo.diffElement);
393
- if (viewIndex === undefined) {
394
- return;
395
- }
396
- if (cell.outputsViewModels.indexOf(key) < 0) {
397
- removedItems.push(key);
398
- } else {
399
- const cellTop = this._list.getCellViewScrollTop(value.cellInfo.diffElement);
400
- const outputIndex = cell.outputsViewModels.indexOf(key);
401
- const outputOffset = value.cellInfo.diffElement.getOutputOffsetInCell(diffSide, outputIndex);
402
- updateItems.push({
403
- cell,
404
- output: key,
405
- cellTop: cellTop,
406
- outputOffset: outputOffset,
407
- forceDisplay: false
408
- });
409
- }
410
- });
411
- activeWebview.removeInsets(removedItems);
412
- if (updateItems.length) {
413
- activeWebview.updateScrollTops(updateItems, []);
414
- }
415
- }
416
- }
417
- async setInput(input, options, context, token) {
418
- this.inlineDiffWidget?.hide();
419
- await super.setInput(input, options, context, token);
420
- const model = await input.resolve();
421
- if (this._model !== model) {
422
- this._detachModel();
423
- this._attachModel(model);
424
- }
425
- this._model = model;
426
- if (this._model === null) {
427
- return;
428
- }
429
- if (this._inlineView) {
430
- this._listViewContainer.style.display = "none";
431
- this.inlineDiffWidget?.show(input, model.modified.notebook, model.original.notebook, options);
432
- } else {
433
- this._listViewContainer.style.display = "block";
434
- this.inlineDiffWidget?.hide();
435
- }
436
- this._revealFirst = true;
437
- this._modifiedResourceDisposableStore.clear();
438
- this._layoutCancellationTokenSource = ( new CancellationTokenSource());
439
- this._modifiedResourceDisposableStore.add(Event.any(
440
- this._model.original.notebook.onDidChangeContent,
441
- this._model.modified.notebook.onDidChangeContent
442
- )(e => {
443
- if (this._model !== null && this.editorService.activeEditor !== input) {
444
- this._layoutCancellationTokenSource?.dispose();
445
- this._layoutCancellationTokenSource = ( new CancellationTokenSource());
446
- this.updateLayout(this._layoutCancellationTokenSource.token);
447
- }
448
- }));
449
- await this._createOriginalWebview(
450
- generateUuid(),
451
- this._model.original.viewType,
452
- this._model.original.resource
453
- );
454
- if (this._originalWebview) {
455
- this._modifiedResourceDisposableStore.add(this._originalWebview);
456
- }
457
- await this._createModifiedWebview(
458
- generateUuid(),
459
- this._model.modified.viewType,
460
- this._model.modified.resource
461
- );
462
- if (this._modifiedWebview) {
463
- this._modifiedResourceDisposableStore.add(this._modifiedWebview);
464
- }
465
- await this.updateLayout(
466
- this._layoutCancellationTokenSource.token,
467
- options?.cellSelections ? cellRangesToIndexes(options.cellSelections) : undefined
468
- );
469
- }
470
- setVisible(visible) {
471
- super.setVisible(visible);
472
- if (!visible) {
473
- this.inlineDiffWidget?.hide();
474
- }
475
- }
476
- _detachModel() {
477
- this._localStore.clear();
478
- this._originalWebview?.dispose();
479
- this._originalWebview?.element.remove();
480
- this._originalWebview = null;
481
- this._modifiedWebview?.dispose();
482
- this._modifiedWebview?.element.remove();
483
- this._modifiedWebview = null;
484
- this.notebookDiffViewModel?.dispose();
485
- this.notebookDiffViewModel = undefined;
486
- this._modifiedResourceDisposableStore.clear();
487
- this._list.clear();
488
- }
489
- _attachModel(model) {
490
- this._model = model;
491
- this._eventDispatcher = ( new NotebookDiffEditorEventDispatcher());
492
- const updateInsets = () => {
493
- scheduleAtNextAnimationFrame(this.window, () => {
494
- if (this._isDisposed) {
495
- return;
496
- }
497
- if (this._modifiedWebview) {
498
- this._updateOutputsOffsetsInWebview(
499
- this._list.scrollTop,
500
- this._list.scrollHeight,
501
- this._modifiedWebview,
502
- diffElement => {
503
- return diffElement.modified;
504
- },
505
- DiffSide.Modified
506
- );
507
- }
508
- if (this._originalWebview) {
509
- this._updateOutputsOffsetsInWebview(
510
- this._list.scrollTop,
511
- this._list.scrollHeight,
512
- this._originalWebview,
513
- diffElement => {
514
- return diffElement.original;
515
- },
516
- DiffSide.Original
517
- );
518
- }
519
- });
520
- };
521
- this._localStore.add(this._list.onDidChangeContentHeight(() => {
522
- updateInsets();
523
- }));
524
- this._localStore.add(this._list.onDidChangeFocus(e => {
525
- if (e.indexes.length && this.notebookDiffViewModel && e.indexes[0] < this.notebookDiffViewModel.items.length) {
526
- const selectedItem = this.notebookDiffViewModel.items[e.indexes[0]];
527
- const changedItems = this.notebookDiffViewModel.items.filter(
528
- item => item.type !== "unchanged" && item.type !== "unchangedMetadata" && item.type !== "placeholder"
529
- );
530
- if (selectedItem && selectedItem?.type !== "placeholder" && selectedItem?.type !== "unchanged" && selectedItem?.type !== "unchangedMetadata") {
531
- return this._currentChangedIndex.set(changedItems.indexOf(selectedItem), undefined);
532
- }
533
- }
534
- return this._currentChangedIndex.set(-1, undefined);
535
- }));
536
- this._localStore.add(this._eventDispatcher.onDidChangeCellLayout(() => {
537
- updateInsets();
538
- }));
539
- const vm = this.notebookDiffViewModel = this._register(( new NotebookDiffViewModel(
540
- this._model,
541
- this.notebookEditorWorkerService,
542
- this.configurationService,
543
- this._eventDispatcher,
544
- this.notebookService,
545
- this.diffEditorCalcuator,
546
- this.fontInfo,
547
- undefined
548
- )));
549
- this._localStore.add(this.notebookDiffViewModel.onDidChangeItems(e => {
550
- this._originalWebview?.removeInsets([...this._originalWebview?.insetMapping.keys()]);
551
- this._modifiedWebview?.removeInsets([...this._modifiedWebview?.insetMapping.keys()]);
552
- if (this._revealFirst && typeof e.firstChangeIndex === "number" && e.firstChangeIndex > -1 && e.firstChangeIndex < this._list.length) {
553
- this._revealFirst = false;
554
- this._list.setFocus([e.firstChangeIndex]);
555
- this._list.reveal(e.firstChangeIndex, 0.3);
556
- }
557
- this._list.splice(e.start, e.deleteCount, e.elements);
558
- if (this.isOverviewRulerEnabled()) {
559
- this._overviewRuler.updateViewModels(vm.items, this._eventDispatcher);
560
- }
561
- }));
562
- }
563
- async _createModifiedWebview(id, viewType, resource) {
564
- this._modifiedWebview?.dispose();
565
- this._modifiedWebview = this.instantiationService.createInstance(BackLayerWebView, this, id, viewType, resource, {
566
- ...this._notebookOptions.computeDiffWebviewOptions(),
567
- fontFamily: this._generateFontFamily()
568
- }, undefined);
569
- this._list.rowsContainer.insertAdjacentElement("afterbegin", this._modifiedWebview.element);
570
- this._modifiedWebview.createWebview(this.window);
571
- this._modifiedWebview.element.style.width = `calc(50% - 16px)`;
572
- this._modifiedWebview.element.style.left = `calc(50%)`;
573
- }
574
- _generateFontFamily() {
575
- return this.fontInfo.fontFamily ?? `"SF Mono", Monaco, Menlo, Consolas, "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace`;
576
- }
577
- async _createOriginalWebview(id, viewType, resource) {
578
- this._originalWebview?.dispose();
579
- this._originalWebview = this.instantiationService.createInstance(BackLayerWebView, this, id, viewType, resource, {
580
- ...this._notebookOptions.computeDiffWebviewOptions(),
581
- fontFamily: this._generateFontFamily()
582
- }, undefined);
583
- this._list.rowsContainer.insertAdjacentElement("afterbegin", this._originalWebview.element);
584
- this._originalWebview.createWebview(this.window);
585
- this._originalWebview.element.style.width = `calc(50% - 16px)`;
586
- this._originalWebview.element.style.left = `16px`;
587
- }
588
- setOptions(options) {
589
- const selections = options?.cellSelections ? cellRangesToIndexes(options.cellSelections) : undefined;
590
- if (selections) {
591
- this._list.setFocus(selections);
592
- }
593
- }
594
- async updateLayout(token, selections) {
595
- if (!this._model || !this.notebookDiffViewModel) {
596
- return;
597
- }
598
- await this.notebookDiffViewModel.computeDiff(token);
599
- if (token.isCancellationRequested) {
600
- return;
601
- }
602
- if (selections) {
603
- this._list.setFocus(selections);
604
- }
605
- }
606
- scheduleOutputHeightAck(cellInfo, outputId, height) {
607
- const diffElement = cellInfo.diffElement;
608
- let diffSide = DiffSide.Original;
609
- if (diffElement instanceof SideBySideDiffElementViewModel) {
610
- const info = CellUri.parse(cellInfo.cellUri);
611
- if (!info) {
612
- return;
613
- }
614
- diffSide = ( info.notebook.toString()) === this._model?.original.resource.toString() ? DiffSide.Original : DiffSide.Modified;
615
- } else {
616
- diffSide = diffElement.type === "insert" ? DiffSide.Modified : DiffSide.Original;
617
- }
618
- const webview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;
619
- scheduleAtNextAnimationFrame(this.window, () => {
620
- webview?.ackHeight([{
621
- cellId: cellInfo.cellId,
622
- outputId,
623
- height
624
- }]);
625
- }, 10);
626
- }
627
- layoutNotebookCell(cell, height) {
628
- const relayout = (cell, height) => {
629
- this._list.updateElementHeight2(cell, height);
630
- };
631
- let disposable = this.pendingLayouts.get(cell);
632
- if (disposable) {
633
- this._localStore.delete(disposable);
634
- }
635
- let r;
636
- const layoutDisposable = scheduleAtNextAnimationFrame(this.window, () => {
637
- this.pendingLayouts.delete(cell);
638
- relayout(cell, height);
639
- r();
640
- });
641
- disposable = toDisposable(() => {
642
- layoutDisposable.dispose();
643
- r();
644
- });
645
- this._localStore.add(disposable);
646
- this.pendingLayouts.set(cell, disposable);
647
- return ( new Promise(resolve => {
648
- r = resolve;
649
- }));
650
- }
651
- setScrollTop(scrollTop) {
652
- this._list.scrollTop = scrollTop;
653
- }
654
- triggerScroll(event) {
655
- this._list.triggerScrollFromMouseWheelEvent(event);
656
- }
657
- firstChange() {
658
- if (!this.notebookDiffViewModel) {
659
- return;
660
- }
661
- const currentViewModels = this.notebookDiffViewModel.items;
662
- const index = currentViewModels.findIndex(
663
- vm => vm.type !== "unchanged" && vm.type !== "unchangedMetadata" && vm.type !== "placeholder"
664
- );
665
- if (index >= 0) {
666
- this._list.setFocus([index]);
667
- this._list.reveal(index);
668
- }
669
- }
670
- lastChange() {
671
- if (!this.notebookDiffViewModel) {
672
- return;
673
- }
674
- const currentViewModels = this.notebookDiffViewModel.items;
675
- const item = currentViewModels.slice().reverse().find(
676
- vm => vm.type !== "unchanged" && vm.type !== "unchangedMetadata" && vm.type !== "placeholder"
677
- );
678
- const index = item ? currentViewModels.indexOf(item) : -1;
679
- if (index >= 0) {
680
- this._list.setFocus([index]);
681
- this._list.reveal(index);
682
- }
683
- }
684
- previousChange() {
685
- if (!this.notebookDiffViewModel) {
686
- return;
687
- }
688
- let currFocus = this._list.getFocus()[0];
689
- if (isNaN(currFocus) || currFocus < 0) {
690
- currFocus = 0;
691
- }
692
- let prevChangeIndex = currFocus - 1;
693
- const currentViewModels = this.notebookDiffViewModel.items;
694
- while (prevChangeIndex >= 0) {
695
- const vm = currentViewModels[prevChangeIndex];
696
- if (vm.type !== "unchanged" && vm.type !== "unchangedMetadata" && vm.type !== "placeholder") {
697
- break;
698
- }
699
- prevChangeIndex--;
700
- }
701
- if (prevChangeIndex >= 0) {
702
- this._list.setFocus([prevChangeIndex]);
703
- this._list.reveal(prevChangeIndex);
704
- } else {
705
- const index = currentViewModels.findLastIndex(
706
- vm => vm.type !== "unchanged" && vm.type !== "unchangedMetadata" && vm.type !== "placeholder"
707
- );
708
- if (index >= 0) {
709
- this._list.setFocus([index]);
710
- this._list.reveal(index);
711
- }
712
- }
713
- }
714
- nextChange() {
715
- if (!this.notebookDiffViewModel) {
716
- return;
717
- }
718
- let currFocus = this._list.getFocus()[0];
719
- if (isNaN(currFocus) || currFocus < 0) {
720
- currFocus = 0;
721
- }
722
- let nextChangeIndex = currFocus + 1;
723
- const currentViewModels = this.notebookDiffViewModel.items;
724
- while (nextChangeIndex < currentViewModels.length) {
725
- const vm = currentViewModels[nextChangeIndex];
726
- if (vm.type !== "unchanged" && vm.type !== "unchangedMetadata" && vm.type !== "placeholder") {
727
- break;
728
- }
729
- nextChangeIndex++;
730
- }
731
- if (nextChangeIndex < currentViewModels.length) {
732
- this._list.setFocus([nextChangeIndex]);
733
- this._list.reveal(nextChangeIndex);
734
- } else {
735
- const index = currentViewModels.findIndex(
736
- vm => vm.type !== "unchanged" && vm.type !== "unchangedMetadata" && vm.type !== "placeholder"
737
- );
738
- if (index >= 0) {
739
- this._list.setFocus([index]);
740
- this._list.reveal(index);
741
- }
742
- }
743
- }
744
- createOutput(cellDiffViewModel, cellViewModel, output, getOffset, diffSide) {
745
- this._insetModifyQueueByOutputId.queue(
746
- output.source.model.outputId + (diffSide === DiffSide.Modified ? "-right" : "left"),
747
- async () => {
748
- const activeWebview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;
749
- if (!activeWebview) {
750
- return;
751
- }
752
- if (!( activeWebview.insetMapping.has(output.source))) {
753
- const cellTop = this._list.getCellViewScrollTop(cellDiffViewModel);
754
- await activeWebview.createOutput({
755
- diffElement: cellDiffViewModel,
756
- cellHandle: cellViewModel.handle,
757
- cellId: cellViewModel.id,
758
- cellUri: cellViewModel.uri
759
- }, output, cellTop, getOffset());
760
- } else {
761
- const cellTop = this._list.getCellViewScrollTop(cellDiffViewModel);
762
- const outputIndex = cellViewModel.outputsViewModels.indexOf(output.source);
763
- const outputOffset = cellDiffViewModel.getOutputOffsetInCell(diffSide, outputIndex);
764
- activeWebview.updateScrollTops([{
765
- cell: cellViewModel,
766
- output: output.source,
767
- cellTop,
768
- outputOffset,
769
- forceDisplay: true
770
- }], []);
771
- }
772
- }
773
- );
774
- }
775
- updateMarkupCellHeight() {}
776
- getCellByInfo(cellInfo) {
777
- return cellInfo.diffElement.getCellByUri(cellInfo.cellUri);
778
- }
779
- getCellById(cellId) {
780
- throw ( new Error("Not implemented"));
781
- }
782
- removeInset(cellDiffViewModel, cellViewModel, displayOutput, diffSide) {
783
- this._insetModifyQueueByOutputId.queue(
784
- displayOutput.model.outputId + (diffSide === DiffSide.Modified ? "-right" : "left"),
785
- async () => {
786
- const activeWebview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;
787
- if (!activeWebview) {
788
- return;
789
- }
790
- if (!( activeWebview.insetMapping.has(displayOutput))) {
791
- return;
792
- }
793
- activeWebview.removeInsets([displayOutput]);
794
- }
795
- );
796
- }
797
- showInset(cellDiffViewModel, cellViewModel, displayOutput, diffSide) {
798
- this._insetModifyQueueByOutputId.queue(
799
- displayOutput.model.outputId + (diffSide === DiffSide.Modified ? "-right" : "left"),
800
- async () => {
801
- const activeWebview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;
802
- if (!activeWebview) {
803
- return;
804
- }
805
- if (!( activeWebview.insetMapping.has(displayOutput))) {
806
- return;
807
- }
808
- const cellTop = this._list.getCellViewScrollTop(cellDiffViewModel);
809
- const outputIndex = cellViewModel.outputsViewModels.indexOf(displayOutput);
810
- const outputOffset = cellDiffViewModel.getOutputOffsetInCell(diffSide, outputIndex);
811
- activeWebview.updateScrollTops([{
812
- cell: cellViewModel,
813
- output: displayOutput,
814
- cellTop,
815
- outputOffset,
816
- forceDisplay: true
817
- }], []);
818
- }
819
- );
820
- }
821
- hideInset(cellDiffViewModel, cellViewModel, output) {
822
- this._modifiedWebview?.hideInset(output);
823
- this._originalWebview?.hideInset(output);
824
- }
825
- getDomNode() {
826
- return this._rootElement;
827
- }
828
- getOverflowContainerDomNode() {
829
- return this._overflowContainer;
830
- }
831
- getControl() {
832
- return this;
833
- }
834
- clearInput() {
835
- this.inlineDiffWidget?.hide();
836
- super.clearInput();
837
- this._modifiedResourceDisposableStore.clear();
838
- this._list?.splice(0, this._list?.length || 0);
839
- this._model = null;
840
- this.notebookDiffViewModel?.dispose();
841
- this.notebookDiffViewModel = undefined;
842
- }
843
- deltaCellOutputContainerClassNames(diffSide, cellId, added, removed) {
844
- if (diffSide === DiffSide.Original) {
845
- this._originalWebview?.deltaCellOutputContainerClassNames(cellId, added, removed);
846
- } else {
847
- this._modifiedWebview?.deltaCellOutputContainerClassNames(cellId, added, removed);
848
- }
849
- }
850
- getLayoutInfo() {
851
- if (!this._list) {
852
- throw ( new Error("Editor is not initalized successfully"));
853
- }
854
- return {
855
- width: this._dimension.width,
856
- height: this._dimension.height,
857
- fontInfo: this.fontInfo,
858
- scrollHeight: this._list?.getScrollHeight() ?? 0,
859
- stickyHeight: 0,
860
- listViewOffsetTop: 0
861
- };
862
- }
863
- layout(dimension, position) {
864
- this._rootElement.classList.toggle("mid-width", dimension.width < 1000 && dimension.width >= 600);
865
- this._rootElement.classList.toggle("narrow-width", dimension.width < 600);
866
- const overviewRulerEnabled = this.isOverviewRulerEnabled();
867
- this._dimension = dimension.with(
868
- dimension.width - (overviewRulerEnabled ? NotebookTextDiffEditor_1.ENTIRE_DIFF_OVERVIEW_WIDTH : 0)
869
- );
870
- this._listViewContainer.style.height = `${dimension.height}px`;
871
- this._listViewContainer.style.width = `${this._dimension.width}px`;
872
- if (this._inlineView) {
873
- this._listViewContainer.style.display = "none";
874
- this.inlineDiffWidget?.setLayout(dimension, position);
875
- } else {
876
- this.inlineDiffWidget?.hide();
877
- this._listViewContainer.style.display = "block";
878
- this._list?.layout(this._dimension.height, this._dimension.width);
879
- if (this._modifiedWebview) {
880
- this._modifiedWebview.element.style.width = `calc(50% - 16px)`;
881
- this._modifiedWebview.element.style.left = `calc(50%)`;
882
- }
883
- if (this._originalWebview) {
884
- this._originalWebview.element.style.width = `calc(50% - 16px)`;
885
- this._originalWebview.element.style.left = `16px`;
886
- }
887
- if (this._webviewTransparentCover) {
888
- this._webviewTransparentCover.style.height = `${this._dimension.height}px`;
889
- this._webviewTransparentCover.style.width = `${this._dimension.width}px`;
890
- }
891
- if (overviewRulerEnabled) {
892
- this._overviewRuler.layout();
893
- }
894
- }
895
- this._lastLayoutProperties = {
896
- dimension,
897
- position
898
- };
899
- this._eventDispatcher?.emit([( new NotebookDiffLayoutChangedEvent({
900
- width: true,
901
- fontInfo: true
902
- }, this.getLayoutInfo()))]);
903
- }
904
- dispose() {
905
- this._isDisposed = true;
906
- this._layoutCancellationTokenSource?.dispose();
907
- this._detachModel();
908
- super.dispose();
909
- }
910
- };
911
- NotebookTextDiffEditor = NotebookTextDiffEditor_1 = ( __decorate([( __param(1, IInstantiationService)), ( __param(2, IThemeService)), ( __param(3, IContextKeyService)), ( __param(4, INotebookEditorWorkerService)), ( __param(5, IConfigurationService)), ( __param(6, ITelemetryService)), ( __param(7, IStorageService)), ( __param(8, INotebookService)), ( __param(9, IEditorService))], NotebookTextDiffEditor));
912
- registerZIndex(ZIndex.Base, 10, "notebook-diff-view-viewport-slider");
913
- registerThemingParticipant((theme, collector) => {
914
- const diffDiagonalFillColor = theme.getColor(diffDiagonalFill);
915
- collector.addRule(`
916
- .notebook-text-diff-editor .diagonal-fill {
917
- background-image: linear-gradient(
918
- -45deg,
919
- ${diffDiagonalFillColor} 12.5%,
920
- #0000 12.5%, #0000 50%,
921
- ${diffDiagonalFillColor} 50%, ${diffDiagonalFillColor} 62.5%,
922
- #0000 62.5%, #0000 100%
923
- );
924
- background-size: 8px 8px;
925
- }
926
- `);
927
- collector.addRule(`.notebook-text-diff-editor .cell-body { margin: ${DIFF_CELL_MARGIN}px; }`);
928
- collector.addRule(
929
- `.notebook-text-diff-editor .cell-placeholder-body { margin: ${DIFF_CELL_MARGIN}px 0; }`
930
- );
931
- });
932
-
933
- export { NotebookTextDiffEditor };