@codingame/monaco-vscode-notebook-service-override 1.85.1

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 (84) hide show
  1. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  2. package/external/tslib/tslib.es6.js +11 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +1 -0
  5. package/notebook.d.ts +5 -0
  6. package/notebook.js +44 -0
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +32 -0
  9. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +6 -0
  10. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +387 -0
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +668 -0
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +109 -0
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +319 -0
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +58 -0
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +173 -0
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +485 -0
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +106 -0
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +67 -0
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +165 -0
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +67 -0
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +238 -0
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +72 -0
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +6 -0
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +168 -0
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +317 -0
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +209 -0
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +87 -0
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +82 -0
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +67 -0
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +93 -0
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +383 -0
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +51 -0
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +46 -0
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +135 -0
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +383 -0
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +117 -0
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +511 -0
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +168 -0
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +57 -0
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +94 -0
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +51 -0
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +702 -0
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +268 -0
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +45 -0
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +1297 -0
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +284 -0
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +563 -0
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +108 -0
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +39 -0
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +6 -0
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +313 -0
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +872 -0
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +13 -0
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +393 -0
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +175 -0
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +1121 -0
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +159 -0
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +339 -0
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl.js +41 -0
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +182 -0
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +106 -0
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +509 -0
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +133 -0
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +342 -0
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +111 -0
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +28 -0
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +65 -0
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +666 -0
  69. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +200 -0
  70. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +80 -0
  71. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +1001 -0
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +103 -0
  73. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +202 -0
  74. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +80 -0
  75. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +98 -0
  76. package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +217 -0
  77. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +89 -0
  78. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +372 -0
  79. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopy.js +706 -0
  80. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +407 -0
  81. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +144 -0
  82. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +129 -0
  83. package/worker.js +1 -0
  84. package/workers/notebook.worker.js +9 -0
@@ -0,0 +1,1297 @@
1
+ import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
+ import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
3
+ import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
5
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
6
+ import { outputEqual, OUTPUT_EDITOR_HEIGHT_MAGIC, PropertyFoldingState, SideBySideDiffElementViewModel, getFormattedMetadataJSON, getFormattedOutputJSON } from './diffElementViewModel.js';
7
+ import { DIFF_CELL_MARGIN, DiffSide, NOTEBOOK_DIFF_CELL_INPUT, NOTEBOOK_DIFF_CELL_PROPERTY, NOTEBOOK_DIFF_CELL_PROPERTY_EXPANDED } from './notebookDiffEditorBrowser.js';
8
+ import { CodeEditorWidget } from 'monaco-editor/esm/vs/editor/browser/widget/codeEditorWidget.js';
9
+ import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
10
+ import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
11
+ import { CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
12
+ import { IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
13
+ import { MenuId, MenuItemAction, IMenuService } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
14
+ import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
15
+ import { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
16
+ import { createAndFillInActionBarActions } from 'monaco-editor/esm/vs/platform/actions/browser/menuEntryActionViewItem.js';
17
+ import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
18
+ import { CodiconActionViewItem } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView';
19
+ import { collapsedIcon, expandedIcon } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
20
+ import { OutputContainer } from './diffElementOutputs.js';
21
+ import { EditorExtensionsRegistry } from 'monaco-editor/esm/vs/editor/browser/editorExtensions.js';
22
+ import { ContextMenuController } from 'monaco-editor/esm/vs/editor/contrib/contextmenu/browser/contextmenu.js';
23
+ import { SnippetController2 } from 'monaco-editor/esm/vs/editor/contrib/snippet/browser/snippetController2.js';
24
+ import { SuggestController } from 'monaco-editor/esm/vs/editor/contrib/suggest/browser/suggestController.js';
25
+ import { MenuPreventer } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/menuPreventer';
26
+ import { SelectionClipboardContributionID } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/selectionClipboard';
27
+ import { TabCompletionController } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/tabCompletion';
28
+ import { renderIcon } from 'monaco-editor/esm/vs/base/browser/ui/iconLabel/iconLabels.js';
29
+ import { ITextModelService } from 'monaco-editor/esm/vs/editor/common/services/resolverService.js';
30
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
31
+ import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
32
+ import { WorkbenchToolBar } from 'monaco-editor/esm/vs/platform/actions/browser/toolbar.js';
33
+ import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
34
+ import { fixedEditorPadding, fixedDiffEditorOptions, fixedEditorOptions } from './diffCellEditorOptions.js';
35
+ import { IAccessibilityService } from 'monaco-editor/esm/vs/platform/accessibility/common/accessibility.js';
36
+ import { DiffEditorWidget } from 'monaco-editor/esm/vs/editor/browser/widget/diffEditor/diffEditorWidget.js';
37
+
38
+ function getOptimizedNestedCodeEditorWidgetOptions() {
39
+ return {
40
+ isSimpleWidget: false,
41
+ contributions: EditorExtensionsRegistry.getSomeEditorContributions([
42
+ MenuPreventer.ID,
43
+ SelectionClipboardContributionID,
44
+ ContextMenuController.ID,
45
+ SuggestController.ID,
46
+ SnippetController2.ID,
47
+ TabCompletionController.ID,
48
+ ])
49
+ };
50
+ }
51
+ let PropertyHeader = class PropertyHeader extends Disposable {
52
+ constructor(cell, propertyHeaderContainer, notebookEditor, accessor, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, themeService, telemetryService, accessibilityService) {
53
+ super();
54
+ this.cell = cell;
55
+ this.propertyHeaderContainer = propertyHeaderContainer;
56
+ this.notebookEditor = notebookEditor;
57
+ this.accessor = accessor;
58
+ this.contextMenuService = contextMenuService;
59
+ this.keybindingService = keybindingService;
60
+ this.notificationService = notificationService;
61
+ this.menuService = menuService;
62
+ this.contextKeyService = contextKeyService;
63
+ this.themeService = themeService;
64
+ this.telemetryService = telemetryService;
65
+ this.accessibilityService = accessibilityService;
66
+ }
67
+ buildHeader() {
68
+ const metadataChanged = this.accessor.checkIfModified(this.cell);
69
+ this._foldingIndicator = dom.append(this.propertyHeaderContainer, dom.$('.property-folding-indicator'));
70
+ this._foldingIndicator.classList.add(this.accessor.prefix);
71
+ this._updateFoldingIcon();
72
+ const metadataStatus = dom.append(this.propertyHeaderContainer, dom.$('div.property-status'));
73
+ this._statusSpan = dom.append(metadataStatus, dom.$('span'));
74
+ this._description = dom.append(metadataStatus, dom.$('span.property-description'));
75
+ if (metadataChanged) {
76
+ this._statusSpan.textContent = this.accessor.changedLabel;
77
+ this._statusSpan.style.fontWeight = 'bold';
78
+ if (metadataChanged.reason) {
79
+ this._description.textContent = metadataChanged.reason;
80
+ }
81
+ this.propertyHeaderContainer.classList.add('modified');
82
+ }
83
+ else {
84
+ this._statusSpan.textContent = this.accessor.unChangedLabel;
85
+ this._description.textContent = '';
86
+ this.propertyHeaderContainer.classList.remove('modified');
87
+ }
88
+ const cellToolbarContainer = dom.append(this.propertyHeaderContainer, dom.$('div.property-toolbar'));
89
+ this._toolbar = ( new WorkbenchToolBar(cellToolbarContainer, {
90
+ actionViewItemProvider: action => {
91
+ if (action instanceof MenuItemAction) {
92
+ const item = ( new CodiconActionViewItem(
93
+ action,
94
+ undefined,
95
+ this.keybindingService,
96
+ this.notificationService,
97
+ this.contextKeyService,
98
+ this.themeService,
99
+ this.contextMenuService,
100
+ this.accessibilityService
101
+ ));
102
+ return item;
103
+ }
104
+ return undefined;
105
+ }
106
+ }, this.menuService, this.contextKeyService, this.contextMenuService, this.keybindingService, this.telemetryService));
107
+ this._register(this._toolbar);
108
+ this._toolbar.context = {
109
+ cell: this.cell
110
+ };
111
+ const scopedContextKeyService = this.contextKeyService.createScoped(cellToolbarContainer);
112
+ this._register(scopedContextKeyService);
113
+ const propertyChanged = NOTEBOOK_DIFF_CELL_PROPERTY.bindTo(scopedContextKeyService);
114
+ propertyChanged.set(!!metadataChanged);
115
+ this._propertyExpanded = NOTEBOOK_DIFF_CELL_PROPERTY_EXPANDED.bindTo(scopedContextKeyService);
116
+ this._menu = this.menuService.createMenu(this.accessor.menuId, scopedContextKeyService);
117
+ this._register(this._menu);
118
+ const actions = [];
119
+ createAndFillInActionBarActions(this._menu, { shouldForwardArgs: true }, actions);
120
+ this._toolbar.setActions(actions);
121
+ this._register(this._menu.onDidChange(() => {
122
+ const actions = [];
123
+ createAndFillInActionBarActions(this._menu, { shouldForwardArgs: true }, actions);
124
+ this._toolbar.setActions(actions);
125
+ }));
126
+ this._register(this.notebookEditor.onMouseUp(e => {
127
+ if (!e.event.target) {
128
+ return;
129
+ }
130
+ const target = e.event.target;
131
+ if (target.classList.contains('codicon-notebook-collapsed') || target.classList.contains('codicon-notebook-expanded')) {
132
+ const parent = target.parentElement;
133
+ if (!parent) {
134
+ return;
135
+ }
136
+ if (!parent.classList.contains(this.accessor.prefix)) {
137
+ return;
138
+ }
139
+ if (!parent.classList.contains('property-folding-indicator')) {
140
+ return;
141
+ }
142
+ const cellViewModel = e.target;
143
+ if (cellViewModel === this.cell) {
144
+ const oldFoldingState = this.accessor.getFoldingState(this.cell);
145
+ this.accessor.updateFoldingState(this.cell, oldFoldingState === PropertyFoldingState.Expanded ? PropertyFoldingState.Collapsed : PropertyFoldingState.Expanded);
146
+ this._updateFoldingIcon();
147
+ this.accessor.updateInfoRendering(this.cell.renderOutput);
148
+ }
149
+ }
150
+ return;
151
+ }));
152
+ this._updateFoldingIcon();
153
+ this.accessor.updateInfoRendering(this.cell.renderOutput);
154
+ }
155
+ refresh() {
156
+ const metadataChanged = this.accessor.checkIfModified(this.cell);
157
+ if (metadataChanged) {
158
+ this._statusSpan.textContent = this.accessor.changedLabel;
159
+ this._statusSpan.style.fontWeight = 'bold';
160
+ if (metadataChanged.reason) {
161
+ this._description.textContent = metadataChanged.reason;
162
+ }
163
+ this.propertyHeaderContainer.classList.add('modified');
164
+ const actions = [];
165
+ createAndFillInActionBarActions(this._menu, undefined, actions);
166
+ this._toolbar.setActions(actions);
167
+ }
168
+ else {
169
+ this._statusSpan.textContent = this.accessor.unChangedLabel;
170
+ this._statusSpan.style.fontWeight = 'normal';
171
+ this._description.textContent = '';
172
+ this.propertyHeaderContainer.classList.remove('modified');
173
+ this._toolbar.setActions([]);
174
+ }
175
+ }
176
+ _updateFoldingIcon() {
177
+ if (this.accessor.getFoldingState(this.cell) === PropertyFoldingState.Collapsed) {
178
+ dom.reset(this._foldingIndicator, renderIcon(collapsedIcon));
179
+ this._propertyExpanded?.set(false);
180
+ }
181
+ else {
182
+ dom.reset(this._foldingIndicator, renderIcon(expandedIcon));
183
+ this._propertyExpanded?.set(true);
184
+ }
185
+ }
186
+ };
187
+ PropertyHeader = ( __decorate([
188
+ ( __param(4, IContextMenuService)),
189
+ ( __param(5, IKeybindingService)),
190
+ ( __param(6, INotificationService)),
191
+ ( __param(7, IMenuService)),
192
+ ( __param(8, IContextKeyService)),
193
+ ( __param(9, IThemeService)),
194
+ ( __param(10, ITelemetryService)),
195
+ ( __param(11, IAccessibilityService))
196
+ ], PropertyHeader));
197
+ class AbstractElementRenderer extends Disposable {
198
+ constructor(notebookEditor, cell, templateData, style, instantiationService, languageService, modelService, textModelService, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, configurationService) {
199
+ super();
200
+ this.notebookEditor = notebookEditor;
201
+ this.cell = cell;
202
+ this.templateData = templateData;
203
+ this.style = style;
204
+ this.instantiationService = instantiationService;
205
+ this.languageService = languageService;
206
+ this.modelService = modelService;
207
+ this.textModelService = textModelService;
208
+ this.contextMenuService = contextMenuService;
209
+ this.keybindingService = keybindingService;
210
+ this.notificationService = notificationService;
211
+ this.menuService = menuService;
212
+ this.contextKeyService = contextKeyService;
213
+ this.configurationService = configurationService;
214
+ this._metadataLocalDisposable = this._register(( new DisposableStore()));
215
+ this._outputLocalDisposable = this._register(( new DisposableStore()));
216
+ this._ignoreMetadata = false;
217
+ this._ignoreOutputs = false;
218
+ this._isDisposed = false;
219
+ this._metadataEditorDisposeStore = this._register(( new DisposableStore()));
220
+ this._outputEditorDisposeStore = this._register(( new DisposableStore()));
221
+ this._register(cell.onDidLayoutChange(e => this.layout(e)));
222
+ this._register(cell.onDidLayoutChange(e => this.updateBorders()));
223
+ this.init();
224
+ this.buildBody();
225
+ this._register(cell.onDidStateChange(() => {
226
+ this.updateOutputRendering(this.cell.renderOutput);
227
+ }));
228
+ }
229
+ buildBody() {
230
+ const body = this.templateData.body;
231
+ this._diffEditorContainer = this.templateData.diffEditorContainer;
232
+ body.classList.remove('left', 'right', 'full');
233
+ switch (this.style) {
234
+ case 'left':
235
+ body.classList.add('left');
236
+ break;
237
+ case 'right':
238
+ body.classList.add('right');
239
+ break;
240
+ default:
241
+ body.classList.add('full');
242
+ break;
243
+ }
244
+ this.styleContainer(this._diffEditorContainer);
245
+ this.updateSourceEditor();
246
+ this._ignoreMetadata = this.configurationService.getValue('notebook.diff.ignoreMetadata');
247
+ if (this._ignoreMetadata) {
248
+ this._disposeMetadata();
249
+ }
250
+ else {
251
+ this._buildMetadata();
252
+ }
253
+ this._ignoreOutputs = this.configurationService.getValue('notebook.diff.ignoreOutputs') || !!(this.notebookEditor.textModel?.transientOptions.transientOutputs);
254
+ if (this._ignoreOutputs) {
255
+ this._disposeOutput();
256
+ }
257
+ else {
258
+ this._buildOutput();
259
+ }
260
+ this._register(this.configurationService.onDidChangeConfiguration(e => {
261
+ let metadataLayoutChange = false;
262
+ let outputLayoutChange = false;
263
+ if (e.affectsConfiguration('notebook.diff.ignoreMetadata')) {
264
+ const newValue = this.configurationService.getValue('notebook.diff.ignoreMetadata');
265
+ if (newValue !== undefined && this._ignoreMetadata !== newValue) {
266
+ this._ignoreMetadata = newValue;
267
+ this._metadataLocalDisposable.clear();
268
+ if (this.configurationService.getValue('notebook.diff.ignoreMetadata')) {
269
+ this._disposeMetadata();
270
+ }
271
+ else {
272
+ this.cell.metadataStatusHeight = 25;
273
+ this._buildMetadata();
274
+ this.updateMetadataRendering();
275
+ metadataLayoutChange = true;
276
+ }
277
+ }
278
+ }
279
+ if (e.affectsConfiguration('notebook.diff.ignoreOutputs')) {
280
+ const newValue = this.configurationService.getValue('notebook.diff.ignoreOutputs');
281
+ if (newValue !== undefined && this._ignoreOutputs !== (newValue || this.notebookEditor.textModel?.transientOptions.transientOutputs)) {
282
+ this._ignoreOutputs = newValue || !!(this.notebookEditor.textModel?.transientOptions.transientOutputs);
283
+ this._outputLocalDisposable.clear();
284
+ if (this._ignoreOutputs) {
285
+ this._disposeOutput();
286
+ }
287
+ else {
288
+ this.cell.outputStatusHeight = 25;
289
+ this._buildOutput();
290
+ outputLayoutChange = true;
291
+ }
292
+ }
293
+ }
294
+ if (metadataLayoutChange || outputLayoutChange) {
295
+ this.layout({ metadataHeight: metadataLayoutChange, outputTotalHeight: outputLayoutChange });
296
+ }
297
+ }));
298
+ }
299
+ updateMetadataRendering() {
300
+ if (this.cell.metadataFoldingState === PropertyFoldingState.Expanded) {
301
+ this._metadataInfoContainer.style.display = 'block';
302
+ if (!this._metadataEditorContainer || !this._metadataEditor) {
303
+ this._metadataEditorContainer = dom.append(this._metadataInfoContainer, dom.$('.metadata-editor-container'));
304
+ this._buildMetadataEditor();
305
+ }
306
+ else {
307
+ this.cell.metadataHeight = this._metadataEditor.getContentHeight();
308
+ }
309
+ }
310
+ else {
311
+ this._metadataInfoContainer.style.display = 'none';
312
+ this.cell.metadataHeight = 0;
313
+ }
314
+ }
315
+ updateOutputRendering(renderRichOutput) {
316
+ if (this.cell.outputFoldingState === PropertyFoldingState.Expanded) {
317
+ this._outputInfoContainer.style.display = 'block';
318
+ if (renderRichOutput) {
319
+ this._hideOutputsRaw();
320
+ this._buildOutputRendererContainer();
321
+ this._showOutputsRenderer();
322
+ this._showOutputsEmptyView();
323
+ }
324
+ else {
325
+ this._hideOutputsRenderer();
326
+ this._buildOutputRawContainer();
327
+ this._showOutputsRaw();
328
+ }
329
+ }
330
+ else {
331
+ this._outputInfoContainer.style.display = 'none';
332
+ this._hideOutputsRaw();
333
+ this._hideOutputsRenderer();
334
+ this._hideOutputsEmptyView();
335
+ }
336
+ }
337
+ _buildOutputRawContainer() {
338
+ if (!this._outputEditorContainer) {
339
+ this._outputEditorContainer = dom.append(this._outputInfoContainer, dom.$('.output-editor-container'));
340
+ this._buildOutputEditor();
341
+ }
342
+ }
343
+ _showOutputsRaw() {
344
+ if (this._outputEditorContainer) {
345
+ this._outputEditorContainer.style.display = 'block';
346
+ this.cell.rawOutputHeight = this._outputEditor.getContentHeight();
347
+ }
348
+ }
349
+ _showOutputsEmptyView() {
350
+ this.cell.layoutChange();
351
+ }
352
+ _hideOutputsRaw() {
353
+ if (this._outputEditorContainer) {
354
+ this._outputEditorContainer.style.display = 'none';
355
+ this.cell.rawOutputHeight = 0;
356
+ }
357
+ }
358
+ _hideOutputsEmptyView() {
359
+ this.cell.layoutChange();
360
+ }
361
+ _applySanitizedMetadataChanges(currentMetadata, newMetadata) {
362
+ const result = {};
363
+ try {
364
+ const newMetadataObj = JSON.parse(newMetadata);
365
+ const keys = ( new Set([...( Object.keys(newMetadataObj))]));
366
+ for (const key of keys) {
367
+ switch (key) {
368
+ case 'inputCollapsed':
369
+ case 'outputCollapsed':
370
+ if (typeof newMetadataObj[key] === 'boolean') {
371
+ result[key] = newMetadataObj[key];
372
+ }
373
+ else {
374
+ result[key] = currentMetadata[key];
375
+ }
376
+ break;
377
+ default:
378
+ result[key] = newMetadataObj[key];
379
+ break;
380
+ }
381
+ }
382
+ const index = this.notebookEditor.textModel.cells.indexOf(this.cell.modified.textModel);
383
+ if (index < 0) {
384
+ return;
385
+ }
386
+ this.notebookEditor.textModel.applyEdits([
387
+ { editType: 3 , index, metadata: result }
388
+ ], true, undefined, () => undefined, undefined, true);
389
+ }
390
+ catch {
391
+ }
392
+ }
393
+ async _buildMetadataEditor() {
394
+ this._metadataEditorDisposeStore.clear();
395
+ if (this.cell instanceof SideBySideDiffElementViewModel) {
396
+ this._metadataEditor = this.instantiationService.createInstance(DiffEditorWidget, this._metadataEditorContainer, {
397
+ ...fixedDiffEditorOptions,
398
+ overflowWidgetsDomNode: this.notebookEditor.getOverflowContainerDomNode(),
399
+ readOnly: false,
400
+ originalEditable: false,
401
+ ignoreTrimWhitespace: false,
402
+ automaticLayout: false,
403
+ dimension: {
404
+ height: this.cell.layoutInfo.metadataHeight,
405
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), true, true)
406
+ }
407
+ }, {
408
+ originalEditor: getOptimizedNestedCodeEditorWidgetOptions(),
409
+ modifiedEditor: getOptimizedNestedCodeEditorWidgetOptions()
410
+ });
411
+ this.layout({ metadataHeight: true });
412
+ this._metadataEditorDisposeStore.add(this._metadataEditor);
413
+ this._metadataEditorContainer?.classList.add('diff');
414
+ const originalMetadataModel = await this.textModelService.createModelReference(CellUri.generateCellPropertyUri(this.cell.originalDocument.uri, this.cell.original.handle, Schemas.vscodeNotebookCellMetadata));
415
+ const modifiedMetadataModel = await this.textModelService.createModelReference(CellUri.generateCellPropertyUri(this.cell.modifiedDocument.uri, this.cell.modified.handle, Schemas.vscodeNotebookCellMetadata));
416
+ this._metadataEditor.setModel({
417
+ original: originalMetadataModel.object.textEditorModel,
418
+ modified: modifiedMetadataModel.object.textEditorModel
419
+ });
420
+ this._metadataEditorDisposeStore.add(originalMetadataModel);
421
+ this._metadataEditorDisposeStore.add(modifiedMetadataModel);
422
+ this.cell.metadataHeight = this._metadataEditor.getContentHeight();
423
+ this._metadataEditorDisposeStore.add(this._metadataEditor.onDidContentSizeChange((e) => {
424
+ if (e.contentHeightChanged && this.cell.metadataFoldingState === PropertyFoldingState.Expanded) {
425
+ this.cell.metadataHeight = e.contentHeight;
426
+ }
427
+ }));
428
+ let respondingToContentChange = false;
429
+ this._metadataEditorDisposeStore.add(modifiedMetadataModel.object.textEditorModel.onDidChangeContent(() => {
430
+ respondingToContentChange = true;
431
+ const value = modifiedMetadataModel.object.textEditorModel.getValue();
432
+ this._applySanitizedMetadataChanges(this.cell.modified.metadata, value);
433
+ this._metadataHeader.refresh();
434
+ respondingToContentChange = false;
435
+ }));
436
+ this._metadataEditorDisposeStore.add(this.cell.modified.textModel.onDidChangeMetadata(() => {
437
+ if (respondingToContentChange) {
438
+ return;
439
+ }
440
+ const modifiedMetadataSource = getFormattedMetadataJSON(this.notebookEditor.textModel, this.cell.modified?.metadata || {}, this.cell.modified?.language);
441
+ modifiedMetadataModel.object.textEditorModel.setValue(modifiedMetadataSource);
442
+ }));
443
+ return;
444
+ }
445
+ else {
446
+ this._metadataEditor = this.instantiationService.createInstance(CodeEditorWidget, this._metadataEditorContainer, {
447
+ ...fixedEditorOptions,
448
+ dimension: {
449
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, true),
450
+ height: this.cell.layoutInfo.metadataHeight
451
+ },
452
+ overflowWidgetsDomNode: this.notebookEditor.getOverflowContainerDomNode(),
453
+ readOnly: false
454
+ }, {});
455
+ this.layout({ metadataHeight: true });
456
+ this._metadataEditorDisposeStore.add(this._metadataEditor);
457
+ const mode = this.languageService.createById('jsonc');
458
+ const originalMetadataSource = getFormattedMetadataJSON(this.notebookEditor.textModel, this.cell.type === 'insert'
459
+ ? this.cell.modified.metadata || {}
460
+ : this.cell.original.metadata || {});
461
+ const uri = this.cell.type === 'insert'
462
+ ? this.cell.modified.uri
463
+ : this.cell.original.uri;
464
+ const handle = this.cell.type === 'insert'
465
+ ? this.cell.modified.handle
466
+ : this.cell.original.handle;
467
+ const modelUri = CellUri.generateCellPropertyUri(uri, handle, Schemas.vscodeNotebookCellMetadata);
468
+ const metadataModel = this.modelService.createModel(originalMetadataSource, mode, modelUri, false);
469
+ this._metadataEditor.setModel(metadataModel);
470
+ this._metadataEditorDisposeStore.add(metadataModel);
471
+ this.cell.metadataHeight = this._metadataEditor.getContentHeight();
472
+ this._metadataEditorDisposeStore.add(this._metadataEditor.onDidContentSizeChange((e) => {
473
+ if (e.contentHeightChanged && this.cell.metadataFoldingState === PropertyFoldingState.Expanded) {
474
+ this.cell.metadataHeight = e.contentHeight;
475
+ }
476
+ }));
477
+ }
478
+ }
479
+ _buildOutputEditor() {
480
+ this._outputEditorDisposeStore.clear();
481
+ if ((this.cell.type === 'modified' || this.cell.type === 'unchanged') && !this.notebookEditor.textModel.transientOptions.transientOutputs) {
482
+ const originalOutputsSource = getFormattedOutputJSON(this.cell.original?.outputs || []);
483
+ const modifiedOutputsSource = getFormattedOutputJSON(this.cell.modified?.outputs || []);
484
+ if (originalOutputsSource !== modifiedOutputsSource) {
485
+ const mode = this.languageService.createById('json');
486
+ const originalModel = this.modelService.createModel(originalOutputsSource, mode, undefined, true);
487
+ const modifiedModel = this.modelService.createModel(modifiedOutputsSource, mode, undefined, true);
488
+ this._outputEditorDisposeStore.add(originalModel);
489
+ this._outputEditorDisposeStore.add(modifiedModel);
490
+ const lineHeight = this.notebookEditor.getLayoutInfo().fontInfo.lineHeight || 17;
491
+ const lineCount = Math.max(originalModel.getLineCount(), modifiedModel.getLineCount());
492
+ this._outputEditor = this.instantiationService.createInstance(DiffEditorWidget, this._outputEditorContainer, {
493
+ ...fixedDiffEditorOptions,
494
+ overflowWidgetsDomNode: this.notebookEditor.getOverflowContainerDomNode(),
495
+ readOnly: true,
496
+ ignoreTrimWhitespace: false,
497
+ automaticLayout: false,
498
+ dimension: {
499
+ height: Math.min(OUTPUT_EDITOR_HEIGHT_MAGIC, this.cell.layoutInfo.rawOutputHeight || lineHeight * lineCount),
500
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, true)
501
+ },
502
+ accessibilityVerbose: this.configurationService.getValue("accessibility.verbosity.diffEditor" ) ?? false
503
+ }, {
504
+ originalEditor: getOptimizedNestedCodeEditorWidgetOptions(),
505
+ modifiedEditor: getOptimizedNestedCodeEditorWidgetOptions()
506
+ });
507
+ this._outputEditorDisposeStore.add(this._outputEditor);
508
+ this._outputEditorContainer?.classList.add('diff');
509
+ this._outputEditor.setModel({
510
+ original: originalModel,
511
+ modified: modifiedModel
512
+ });
513
+ this._outputEditor.restoreViewState(this.cell.getOutputEditorViewState());
514
+ this.cell.rawOutputHeight = this._outputEditor.getContentHeight();
515
+ this._outputEditorDisposeStore.add(this._outputEditor.onDidContentSizeChange((e) => {
516
+ if (e.contentHeightChanged && this.cell.outputFoldingState === PropertyFoldingState.Expanded) {
517
+ this.cell.rawOutputHeight = e.contentHeight;
518
+ }
519
+ }));
520
+ this._outputEditorDisposeStore.add(this.cell.modified.textModel.onDidChangeOutputs(() => {
521
+ const modifiedOutputsSource = getFormattedOutputJSON(this.cell.modified?.outputs || []);
522
+ modifiedModel.setValue(modifiedOutputsSource);
523
+ this._outputHeader.refresh();
524
+ }));
525
+ return;
526
+ }
527
+ }
528
+ this._outputEditor = this.instantiationService.createInstance(CodeEditorWidget, this._outputEditorContainer, {
529
+ ...fixedEditorOptions,
530
+ dimension: {
531
+ width: Math.min(OUTPUT_EDITOR_HEIGHT_MAGIC, this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, this.cell.type === 'unchanged' || this.cell.type === 'modified') - 32),
532
+ height: this.cell.layoutInfo.rawOutputHeight
533
+ },
534
+ overflowWidgetsDomNode: this.notebookEditor.getOverflowContainerDomNode()
535
+ }, {});
536
+ this._outputEditorDisposeStore.add(this._outputEditor);
537
+ const mode = this.languageService.createById('json');
538
+ const originaloutputSource = getFormattedOutputJSON(this.notebookEditor.textModel.transientOptions.transientOutputs
539
+ ? []
540
+ : this.cell.type === 'insert'
541
+ ? this.cell.modified.outputs || []
542
+ : this.cell.original.outputs || []);
543
+ const outputModel = this.modelService.createModel(originaloutputSource, mode, undefined, true);
544
+ this._outputEditorDisposeStore.add(outputModel);
545
+ this._outputEditor.setModel(outputModel);
546
+ this._outputEditor.restoreViewState(this.cell.getOutputEditorViewState());
547
+ this.cell.rawOutputHeight = this._outputEditor.getContentHeight();
548
+ this._outputEditorDisposeStore.add(this._outputEditor.onDidContentSizeChange((e) => {
549
+ if (e.contentHeightChanged && this.cell.outputFoldingState === PropertyFoldingState.Expanded) {
550
+ this.cell.rawOutputHeight = e.contentHeight;
551
+ }
552
+ }));
553
+ }
554
+ layoutNotebookCell() {
555
+ this.notebookEditor.layoutNotebookCell(this.cell, this.cell.layoutInfo.totalHeight);
556
+ }
557
+ updateBorders() {
558
+ this.templateData.leftBorder.style.height = `${this.cell.layoutInfo.totalHeight - 32}px`;
559
+ this.templateData.rightBorder.style.height = `${this.cell.layoutInfo.totalHeight - 32}px`;
560
+ this.templateData.bottomBorder.style.top = `${this.cell.layoutInfo.totalHeight - 32}px`;
561
+ }
562
+ dispose() {
563
+ if (this._outputEditor) {
564
+ this.cell.saveOutputEditorViewState(this._outputEditor.saveViewState());
565
+ }
566
+ if (this._metadataEditor) {
567
+ this.cell.saveMetadataEditorViewState(this._metadataEditor.saveViewState());
568
+ }
569
+ this._metadataEditorDisposeStore.dispose();
570
+ this._outputEditorDisposeStore.dispose();
571
+ this._isDisposed = true;
572
+ super.dispose();
573
+ }
574
+ }
575
+ class SingleSideDiffElement extends AbstractElementRenderer {
576
+ constructor(notebookEditor, cell, templateData, style, instantiationService, languageService, modelService, textModelService, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, configurationService) {
577
+ super(notebookEditor, cell, templateData, style, instantiationService, languageService, modelService, textModelService, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, configurationService);
578
+ this.cell = cell;
579
+ this.templateData = templateData;
580
+ }
581
+ init() {
582
+ this._diagonalFill = this.templateData.diagonalFill;
583
+ }
584
+ buildBody() {
585
+ const body = this.templateData.body;
586
+ this._diffEditorContainer = this.templateData.diffEditorContainer;
587
+ body.classList.remove('left', 'right', 'full');
588
+ switch (this.style) {
589
+ case 'left':
590
+ body.classList.add('left');
591
+ break;
592
+ case 'right':
593
+ body.classList.add('right');
594
+ break;
595
+ default:
596
+ body.classList.add('full');
597
+ break;
598
+ }
599
+ this.styleContainer(this._diffEditorContainer);
600
+ this.updateSourceEditor();
601
+ if (this.configurationService.getValue('notebook.diff.ignoreMetadata')) {
602
+ this._disposeMetadata();
603
+ }
604
+ else {
605
+ this._buildMetadata();
606
+ }
607
+ if (this.configurationService.getValue('notebook.diff.ignoreOutputs') || this.notebookEditor.textModel?.transientOptions.transientOutputs) {
608
+ this._disposeOutput();
609
+ }
610
+ else {
611
+ this._buildOutput();
612
+ }
613
+ this._register(this.configurationService.onDidChangeConfiguration(e => {
614
+ let metadataLayoutChange = false;
615
+ let outputLayoutChange = false;
616
+ if (e.affectsConfiguration('notebook.diff.ignoreMetadata')) {
617
+ this._metadataLocalDisposable.clear();
618
+ if (this.configurationService.getValue('notebook.diff.ignoreMetadata')) {
619
+ this._disposeMetadata();
620
+ }
621
+ else {
622
+ this.cell.metadataStatusHeight = 25;
623
+ this._buildMetadata();
624
+ this.updateMetadataRendering();
625
+ metadataLayoutChange = true;
626
+ }
627
+ }
628
+ if (e.affectsConfiguration('notebook.diff.ignoreOutputs')) {
629
+ this._outputLocalDisposable.clear();
630
+ if (this.configurationService.getValue('notebook.diff.ignoreOutputs') || this.notebookEditor.textModel?.transientOptions.transientOutputs) {
631
+ this._disposeOutput();
632
+ }
633
+ else {
634
+ this.cell.outputStatusHeight = 25;
635
+ this._buildOutput();
636
+ outputLayoutChange = true;
637
+ }
638
+ }
639
+ if (metadataLayoutChange || outputLayoutChange) {
640
+ this.layout({ metadataHeight: metadataLayoutChange, outputTotalHeight: outputLayoutChange });
641
+ }
642
+ }));
643
+ }
644
+ _disposeMetadata() {
645
+ this.cell.metadataStatusHeight = 0;
646
+ this.cell.metadataHeight = 0;
647
+ this.templateData.metadataHeaderContainer.style.display = 'none';
648
+ this.templateData.metadataInfoContainer.style.display = 'none';
649
+ this._metadataEditor = undefined;
650
+ }
651
+ _buildMetadata() {
652
+ this._metadataHeaderContainer = this.templateData.metadataHeaderContainer;
653
+ this._metadataInfoContainer = this.templateData.metadataInfoContainer;
654
+ this._metadataHeaderContainer.style.display = 'flex';
655
+ this._metadataInfoContainer.style.display = 'block';
656
+ this._metadataHeaderContainer.innerText = '';
657
+ this._metadataInfoContainer.innerText = '';
658
+ this._metadataHeader = this.instantiationService.createInstance(PropertyHeader, this.cell, this._metadataHeaderContainer, this.notebookEditor, {
659
+ updateInfoRendering: this.updateMetadataRendering.bind(this),
660
+ checkIfModified: (cell) => {
661
+ return cell.checkMetadataIfModified();
662
+ },
663
+ getFoldingState: (cell) => {
664
+ return cell.metadataFoldingState;
665
+ },
666
+ updateFoldingState: (cell, state) => {
667
+ cell.metadataFoldingState = state;
668
+ },
669
+ unChangedLabel: 'Metadata',
670
+ changedLabel: 'Metadata changed',
671
+ prefix: 'metadata',
672
+ menuId: MenuId.NotebookDiffCellMetadataTitle
673
+ });
674
+ this._metadataLocalDisposable.add(this._metadataHeader);
675
+ this._metadataHeader.buildHeader();
676
+ }
677
+ _buildOutput() {
678
+ this.templateData.outputHeaderContainer.style.display = 'flex';
679
+ this.templateData.outputInfoContainer.style.display = 'block';
680
+ this._outputHeaderContainer = this.templateData.outputHeaderContainer;
681
+ this._outputInfoContainer = this.templateData.outputInfoContainer;
682
+ this._outputHeaderContainer.innerText = '';
683
+ this._outputInfoContainer.innerText = '';
684
+ this._outputHeader = this.instantiationService.createInstance(PropertyHeader, this.cell, this._outputHeaderContainer, this.notebookEditor, {
685
+ updateInfoRendering: this.updateOutputRendering.bind(this),
686
+ checkIfModified: (cell) => {
687
+ return cell.checkIfOutputsModified();
688
+ },
689
+ getFoldingState: (cell) => {
690
+ return cell.outputFoldingState;
691
+ },
692
+ updateFoldingState: (cell, state) => {
693
+ cell.outputFoldingState = state;
694
+ },
695
+ unChangedLabel: 'Outputs',
696
+ changedLabel: 'Outputs changed',
697
+ prefix: 'output',
698
+ menuId: MenuId.NotebookDiffCellOutputsTitle
699
+ });
700
+ this._outputLocalDisposable.add(this._outputHeader);
701
+ this._outputHeader.buildHeader();
702
+ }
703
+ _disposeOutput() {
704
+ this._hideOutputsRaw();
705
+ this._hideOutputsRenderer();
706
+ this._hideOutputsEmptyView();
707
+ this.cell.rawOutputHeight = 0;
708
+ this.cell.outputStatusHeight = 0;
709
+ this.templateData.outputHeaderContainer.style.display = 'none';
710
+ this.templateData.outputInfoContainer.style.display = 'none';
711
+ this._outputViewContainer = undefined;
712
+ }
713
+ }
714
+ let DeletedElement = class DeletedElement extends SingleSideDiffElement {
715
+ constructor(notebookEditor, cell, templateData, languageService, modelService, textModelService, instantiationService, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, configurationService) {
716
+ super(notebookEditor, cell, templateData, 'left', instantiationService, languageService, modelService, textModelService, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, configurationService);
717
+ }
718
+ styleContainer(container) {
719
+ container.classList.remove('inserted');
720
+ container.classList.add('removed');
721
+ }
722
+ updateSourceEditor() {
723
+ const originalCell = this.cell.original;
724
+ const lineCount = originalCell.textModel.textBuffer.getLineCount();
725
+ const lineHeight = this.notebookEditor.getLayoutInfo().fontInfo.lineHeight || 17;
726
+ const editorHeight = lineCount * lineHeight + fixedEditorPadding.top + fixedEditorPadding.bottom;
727
+ this._editor = this.templateData.sourceEditor;
728
+ this._editor.layout({
729
+ width: (this.notebookEditor.getLayoutInfo().width - 2 * DIFF_CELL_MARGIN) / 2 - 18,
730
+ height: editorHeight
731
+ });
732
+ this.cell.editorHeight = editorHeight;
733
+ this._register(this._editor.onDidContentSizeChange((e) => {
734
+ if (e.contentHeightChanged && this.cell.layoutInfo.editorHeight !== e.contentHeight) {
735
+ this.cell.editorHeight = e.contentHeight;
736
+ }
737
+ }));
738
+ this.textModelService.createModelReference(originalCell.uri).then(ref => {
739
+ if (this._isDisposed) {
740
+ return;
741
+ }
742
+ this._register(ref);
743
+ const textModel = ref.object.textEditorModel;
744
+ this._editor.setModel(textModel);
745
+ this.cell.editorHeight = this._editor.getContentHeight();
746
+ });
747
+ }
748
+ layout(state) {
749
+ dom.scheduleAtNextAnimationFrame(dom.getWindow(this._diffEditorContainer), () => {
750
+ if (state.editorHeight || state.outerWidth) {
751
+ this._editor.layout({
752
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, false),
753
+ height: this.cell.layoutInfo.editorHeight
754
+ });
755
+ }
756
+ if (state.metadataHeight || state.outerWidth) {
757
+ this._metadataEditor?.layout({
758
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, false),
759
+ height: this.cell.layoutInfo.metadataHeight
760
+ });
761
+ }
762
+ if (state.outputTotalHeight || state.outerWidth) {
763
+ this._outputEditor?.layout({
764
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, false),
765
+ height: this.cell.layoutInfo.outputTotalHeight
766
+ });
767
+ }
768
+ if (this._diagonalFill) {
769
+ this._diagonalFill.style.height = `${this.cell.layoutInfo.totalHeight - 32}px`;
770
+ }
771
+ this.layoutNotebookCell();
772
+ });
773
+ }
774
+ _buildOutputRendererContainer() {
775
+ if (!this._outputViewContainer) {
776
+ this._outputViewContainer = dom.append(this._outputInfoContainer, dom.$('.output-view-container'));
777
+ this._outputEmptyElement = dom.append(this._outputViewContainer, dom.$('.output-empty-view'));
778
+ const span = dom.append(this._outputEmptyElement, dom.$('span'));
779
+ span.innerText = 'No outputs to render';
780
+ if (this.cell.original.outputs.length === 0) {
781
+ this._outputEmptyElement.style.display = 'block';
782
+ }
783
+ else {
784
+ this._outputEmptyElement.style.display = 'none';
785
+ }
786
+ this.cell.layoutChange();
787
+ this._outputLeftView = this.instantiationService.createInstance(OutputContainer, this.notebookEditor, this.notebookEditor.textModel, this.cell, this.cell.original, DiffSide.Original, this._outputViewContainer);
788
+ this._register(this._outputLeftView);
789
+ this._outputLeftView.render();
790
+ const removedOutputRenderListener = this.notebookEditor.onDidDynamicOutputRendered(e => {
791
+ if (( e.cell.uri.toString()) === ( this.cell.original.uri.toString())) {
792
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Original, this.cell.original.id, ['nb-cellDeleted'], []);
793
+ removedOutputRenderListener.dispose();
794
+ }
795
+ });
796
+ this._register(removedOutputRenderListener);
797
+ }
798
+ this._outputViewContainer.style.display = 'block';
799
+ }
800
+ _decorate() {
801
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Original, this.cell.original.id, ['nb-cellDeleted'], []);
802
+ }
803
+ _showOutputsRenderer() {
804
+ if (this._outputViewContainer) {
805
+ this._outputViewContainer.style.display = 'block';
806
+ this._outputLeftView?.showOutputs();
807
+ this._decorate();
808
+ }
809
+ }
810
+ _hideOutputsRenderer() {
811
+ if (this._outputViewContainer) {
812
+ this._outputViewContainer.style.display = 'none';
813
+ this._outputLeftView?.hideOutputs();
814
+ }
815
+ }
816
+ dispose() {
817
+ if (this._editor) {
818
+ this.cell.saveSpirceEditorViewState(this._editor.saveViewState());
819
+ }
820
+ super.dispose();
821
+ }
822
+ };
823
+ DeletedElement = ( __decorate([
824
+ ( __param(3, ILanguageService)),
825
+ ( __param(4, IModelService)),
826
+ ( __param(5, ITextModelService)),
827
+ ( __param(6, IInstantiationService)),
828
+ ( __param(7, IContextMenuService)),
829
+ ( __param(8, IKeybindingService)),
830
+ ( __param(9, INotificationService)),
831
+ ( __param(10, IMenuService)),
832
+ ( __param(11, IContextKeyService)),
833
+ ( __param(12, IConfigurationService))
834
+ ], DeletedElement));
835
+ let InsertElement = class InsertElement extends SingleSideDiffElement {
836
+ constructor(notebookEditor, cell, templateData, instantiationService, languageService, modelService, textModelService, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, configurationService) {
837
+ super(notebookEditor, cell, templateData, 'right', instantiationService, languageService, modelService, textModelService, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, configurationService);
838
+ }
839
+ styleContainer(container) {
840
+ container.classList.remove('removed');
841
+ container.classList.add('inserted');
842
+ }
843
+ updateSourceEditor() {
844
+ const modifiedCell = this.cell.modified;
845
+ const lineCount = modifiedCell.textModel.textBuffer.getLineCount();
846
+ const lineHeight = this.notebookEditor.getLayoutInfo().fontInfo.lineHeight || 17;
847
+ const editorHeight = lineCount * lineHeight + fixedEditorPadding.top + fixedEditorPadding.bottom;
848
+ this._editor = this.templateData.sourceEditor;
849
+ this._editor.layout({
850
+ width: (this.notebookEditor.getLayoutInfo().width - 2 * DIFF_CELL_MARGIN) / 2 - 18,
851
+ height: editorHeight
852
+ });
853
+ this._editor.updateOptions({ readOnly: false });
854
+ this.cell.editorHeight = editorHeight;
855
+ this._register(this._editor.onDidContentSizeChange((e) => {
856
+ if (e.contentHeightChanged && this.cell.layoutInfo.editorHeight !== e.contentHeight) {
857
+ this.cell.editorHeight = e.contentHeight;
858
+ }
859
+ }));
860
+ this.textModelService.createModelReference(modifiedCell.uri).then(ref => {
861
+ if (this._isDisposed) {
862
+ return;
863
+ }
864
+ this._register(ref);
865
+ const textModel = ref.object.textEditorModel;
866
+ this._editor.setModel(textModel);
867
+ this._editor.restoreViewState(this.cell.getSourceEditorViewState());
868
+ this.cell.editorHeight = this._editor.getContentHeight();
869
+ });
870
+ }
871
+ _buildOutputRendererContainer() {
872
+ if (!this._outputViewContainer) {
873
+ this._outputViewContainer = dom.append(this._outputInfoContainer, dom.$('.output-view-container'));
874
+ this._outputEmptyElement = dom.append(this._outputViewContainer, dom.$('.output-empty-view'));
875
+ this._outputEmptyElement.innerText = 'No outputs to render';
876
+ if (this.cell.modified.outputs.length === 0) {
877
+ this._outputEmptyElement.style.display = 'block';
878
+ }
879
+ else {
880
+ this._outputEmptyElement.style.display = 'none';
881
+ }
882
+ this.cell.layoutChange();
883
+ this._outputRightView = this.instantiationService.createInstance(OutputContainer, this.notebookEditor, this.notebookEditor.textModel, this.cell, this.cell.modified, DiffSide.Modified, this._outputViewContainer);
884
+ this._register(this._outputRightView);
885
+ this._outputRightView.render();
886
+ const insertOutputRenderListener = this.notebookEditor.onDidDynamicOutputRendered(e => {
887
+ if (( e.cell.uri.toString()) === ( this.cell.modified.uri.toString())) {
888
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Modified, this.cell.modified.id, ['nb-cellAdded'], []);
889
+ insertOutputRenderListener.dispose();
890
+ }
891
+ });
892
+ this._register(insertOutputRenderListener);
893
+ }
894
+ this._outputViewContainer.style.display = 'block';
895
+ }
896
+ _decorate() {
897
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Modified, this.cell.modified.id, ['nb-cellAdded'], []);
898
+ }
899
+ _showOutputsRenderer() {
900
+ if (this._outputViewContainer) {
901
+ this._outputViewContainer.style.display = 'block';
902
+ this._outputRightView?.showOutputs();
903
+ this._decorate();
904
+ }
905
+ }
906
+ _hideOutputsRenderer() {
907
+ if (this._outputViewContainer) {
908
+ this._outputViewContainer.style.display = 'none';
909
+ this._outputRightView?.hideOutputs();
910
+ }
911
+ }
912
+ layout(state) {
913
+ dom.scheduleAtNextAnimationFrame(dom.getWindow(this._diffEditorContainer), () => {
914
+ if (state.editorHeight || state.outerWidth) {
915
+ this._editor.layout({
916
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, false),
917
+ height: this.cell.layoutInfo.editorHeight
918
+ });
919
+ }
920
+ if (state.metadataHeight || state.outerWidth) {
921
+ this._metadataEditor?.layout({
922
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, true),
923
+ height: this.cell.layoutInfo.metadataHeight
924
+ });
925
+ }
926
+ if (state.outputTotalHeight || state.outerWidth) {
927
+ this._outputEditor?.layout({
928
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, false),
929
+ height: this.cell.layoutInfo.outputTotalHeight
930
+ });
931
+ }
932
+ this.layoutNotebookCell();
933
+ if (this._diagonalFill) {
934
+ this._diagonalFill.style.height = `${this.cell.layoutInfo.editorHeight + this.cell.layoutInfo.editorMargin + this.cell.layoutInfo.metadataStatusHeight + this.cell.layoutInfo.metadataHeight + this.cell.layoutInfo.outputTotalHeight + this.cell.layoutInfo.outputStatusHeight}px`;
935
+ }
936
+ });
937
+ }
938
+ dispose() {
939
+ if (this._editor) {
940
+ this.cell.saveSpirceEditorViewState(this._editor.saveViewState());
941
+ }
942
+ super.dispose();
943
+ }
944
+ };
945
+ InsertElement = ( __decorate([
946
+ ( __param(3, IInstantiationService)),
947
+ ( __param(4, ILanguageService)),
948
+ ( __param(5, IModelService)),
949
+ ( __param(6, ITextModelService)),
950
+ ( __param(7, IContextMenuService)),
951
+ ( __param(8, IKeybindingService)),
952
+ ( __param(9, INotificationService)),
953
+ ( __param(10, IMenuService)),
954
+ ( __param(11, IContextKeyService)),
955
+ ( __param(12, IConfigurationService))
956
+ ], InsertElement));
957
+ let ModifiedElement = class ModifiedElement extends AbstractElementRenderer {
958
+ constructor(notebookEditor, cell, templateData, instantiationService, languageService, modelService, textModelService, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, configurationService) {
959
+ super(notebookEditor, cell, templateData, 'full', instantiationService, languageService, modelService, textModelService, contextMenuService, keybindingService, notificationService, menuService, contextKeyService, configurationService);
960
+ this.cell = cell;
961
+ this.templateData = templateData;
962
+ this._editorViewStateChanged = false;
963
+ }
964
+ init() { }
965
+ styleContainer(container) {
966
+ container.classList.remove('inserted', 'removed');
967
+ }
968
+ _disposeMetadata() {
969
+ this.cell.metadataStatusHeight = 0;
970
+ this.cell.metadataHeight = 0;
971
+ this.templateData.metadataHeaderContainer.style.display = 'none';
972
+ this.templateData.metadataInfoContainer.style.display = 'none';
973
+ this._metadataEditor = undefined;
974
+ }
975
+ _buildMetadata() {
976
+ this._metadataHeaderContainer = this.templateData.metadataHeaderContainer;
977
+ this._metadataInfoContainer = this.templateData.metadataInfoContainer;
978
+ this._metadataHeaderContainer.style.display = 'flex';
979
+ this._metadataInfoContainer.style.display = 'block';
980
+ this._metadataHeaderContainer.innerText = '';
981
+ this._metadataInfoContainer.innerText = '';
982
+ this._metadataHeader = this.instantiationService.createInstance(PropertyHeader, this.cell, this._metadataHeaderContainer, this.notebookEditor, {
983
+ updateInfoRendering: this.updateMetadataRendering.bind(this),
984
+ checkIfModified: (cell) => {
985
+ return cell.checkMetadataIfModified();
986
+ },
987
+ getFoldingState: (cell) => {
988
+ return cell.metadataFoldingState;
989
+ },
990
+ updateFoldingState: (cell, state) => {
991
+ cell.metadataFoldingState = state;
992
+ },
993
+ unChangedLabel: 'Metadata',
994
+ changedLabel: 'Metadata changed',
995
+ prefix: 'metadata',
996
+ menuId: MenuId.NotebookDiffCellMetadataTitle
997
+ });
998
+ this._metadataLocalDisposable.add(this._metadataHeader);
999
+ this._metadataHeader.buildHeader();
1000
+ }
1001
+ _disposeOutput() {
1002
+ this._hideOutputsRaw();
1003
+ this._hideOutputsRenderer();
1004
+ this._hideOutputsEmptyView();
1005
+ this.cell.rawOutputHeight = 0;
1006
+ this.cell.outputStatusHeight = 0;
1007
+ this.templateData.outputHeaderContainer.style.display = 'none';
1008
+ this.templateData.outputInfoContainer.style.display = 'none';
1009
+ this._outputViewContainer = undefined;
1010
+ }
1011
+ _buildOutput() {
1012
+ this.templateData.outputHeaderContainer.style.display = 'flex';
1013
+ this.templateData.outputInfoContainer.style.display = 'block';
1014
+ this._outputHeaderContainer = this.templateData.outputHeaderContainer;
1015
+ this._outputInfoContainer = this.templateData.outputInfoContainer;
1016
+ this._outputHeaderContainer.innerText = '';
1017
+ this._outputInfoContainer.innerText = '';
1018
+ if (this.cell.checkIfOutputsModified()) {
1019
+ this._outputInfoContainer.classList.add('modified');
1020
+ }
1021
+ else {
1022
+ this._outputInfoContainer.classList.remove('modified');
1023
+ }
1024
+ this._outputHeader = this.instantiationService.createInstance(PropertyHeader, this.cell, this._outputHeaderContainer, this.notebookEditor, {
1025
+ updateInfoRendering: this.updateOutputRendering.bind(this),
1026
+ checkIfModified: (cell) => {
1027
+ return cell.checkIfOutputsModified();
1028
+ },
1029
+ getFoldingState: (cell) => {
1030
+ return cell.outputFoldingState;
1031
+ },
1032
+ updateFoldingState: (cell, state) => {
1033
+ cell.outputFoldingState = state;
1034
+ },
1035
+ unChangedLabel: 'Outputs',
1036
+ changedLabel: 'Outputs changed',
1037
+ prefix: 'output',
1038
+ menuId: MenuId.NotebookDiffCellOutputsTitle
1039
+ });
1040
+ this._outputLocalDisposable.add(this._outputHeader);
1041
+ this._outputHeader.buildHeader();
1042
+ }
1043
+ _buildOutputRendererContainer() {
1044
+ if (!this._outputViewContainer) {
1045
+ this._outputViewContainer = dom.append(this._outputInfoContainer, dom.$('.output-view-container'));
1046
+ this._outputEmptyElement = dom.append(this._outputViewContainer, dom.$('.output-empty-view'));
1047
+ this._outputEmptyElement.innerText = 'No outputs to render';
1048
+ if (!this.cell.checkIfOutputsModified() && this.cell.modified.outputs.length === 0) {
1049
+ this._outputEmptyElement.style.display = 'block';
1050
+ }
1051
+ else {
1052
+ this._outputEmptyElement.style.display = 'none';
1053
+ }
1054
+ this.cell.layoutChange();
1055
+ this._register(this.cell.modified.textModel.onDidChangeOutputs(() => {
1056
+ if (!this.cell.checkIfOutputsModified() && this.cell.modified.outputs.length === 0) {
1057
+ this._outputEmptyElement.style.display = 'block';
1058
+ }
1059
+ else {
1060
+ this._outputEmptyElement.style.display = 'none';
1061
+ }
1062
+ this._decorate();
1063
+ }));
1064
+ this._outputLeftContainer = dom.append(this._outputViewContainer, dom.$('.output-view-container-left'));
1065
+ this._outputRightContainer = dom.append(this._outputViewContainer, dom.$('.output-view-container-right'));
1066
+ this._outputMetadataContainer = dom.append(this._outputViewContainer, dom.$('.output-view-container-metadata'));
1067
+ const outputModified = this.cell.checkIfOutputsModified();
1068
+ const outputMetadataChangeOnly = outputModified
1069
+ && outputModified.kind === 1
1070
+ && this.cell.original.outputs.length === 1
1071
+ && this.cell.modified.outputs.length === 1
1072
+ && outputEqual(this.cell.original.outputs[0], this.cell.modified.outputs[0]) === 1 ;
1073
+ if (outputModified && !outputMetadataChangeOnly) {
1074
+ const originalOutputRenderListener = this.notebookEditor.onDidDynamicOutputRendered(e => {
1075
+ if (( e.cell.uri.toString()) === ( this.cell.original.uri.toString()) && this.cell.checkIfOutputsModified()) {
1076
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Original, this.cell.original.id, ['nb-cellDeleted'], []);
1077
+ originalOutputRenderListener.dispose();
1078
+ }
1079
+ });
1080
+ const modifiedOutputRenderListener = this.notebookEditor.onDidDynamicOutputRendered(e => {
1081
+ if (( e.cell.uri.toString()) === ( this.cell.modified.uri.toString()) && this.cell.checkIfOutputsModified()) {
1082
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Modified, this.cell.modified.id, ['nb-cellAdded'], []);
1083
+ modifiedOutputRenderListener.dispose();
1084
+ }
1085
+ });
1086
+ this._register(originalOutputRenderListener);
1087
+ this._register(modifiedOutputRenderListener);
1088
+ }
1089
+ this._outputLeftView = this.instantiationService.createInstance(OutputContainer, this.notebookEditor, this.notebookEditor.textModel, this.cell, this.cell.original, DiffSide.Original, this._outputLeftContainer);
1090
+ this._outputLeftView.render();
1091
+ this._register(this._outputLeftView);
1092
+ this._outputRightView = this.instantiationService.createInstance(OutputContainer, this.notebookEditor, this.notebookEditor.textModel, this.cell, this.cell.modified, DiffSide.Modified, this._outputRightContainer);
1093
+ this._outputRightView.render();
1094
+ this._register(this._outputRightView);
1095
+ if (outputModified && !outputMetadataChangeOnly) {
1096
+ this._decorate();
1097
+ }
1098
+ if (outputMetadataChangeOnly) {
1099
+ this._outputMetadataContainer.style.top = `${this.cell.layoutInfo.rawOutputHeight}px`;
1100
+ this._outputMetadataEditor = this.instantiationService.createInstance(DiffEditorWidget, this._outputMetadataContainer, {
1101
+ ...fixedDiffEditorOptions,
1102
+ overflowWidgetsDomNode: this.notebookEditor.getOverflowContainerDomNode(),
1103
+ readOnly: true,
1104
+ ignoreTrimWhitespace: false,
1105
+ automaticLayout: false,
1106
+ dimension: {
1107
+ height: OUTPUT_EDITOR_HEIGHT_MAGIC,
1108
+ width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), false, true)
1109
+ }
1110
+ }, {
1111
+ originalEditor: getOptimizedNestedCodeEditorWidgetOptions(),
1112
+ modifiedEditor: getOptimizedNestedCodeEditorWidgetOptions()
1113
+ });
1114
+ this._register(this._outputMetadataEditor);
1115
+ const originalOutputMetadataSource = JSON.stringify(this.cell.original.outputs[0].metadata ?? {}, undefined, '\t');
1116
+ const modifiedOutputMetadataSource = JSON.stringify(this.cell.modified.outputs[0].metadata ?? {}, undefined, '\t');
1117
+ const mode = this.languageService.createById('json');
1118
+ const originalModel = this.modelService.createModel(originalOutputMetadataSource, mode, undefined, true);
1119
+ const modifiedModel = this.modelService.createModel(modifiedOutputMetadataSource, mode, undefined, true);
1120
+ this._outputMetadataEditor.setModel({
1121
+ original: originalModel,
1122
+ modified: modifiedModel
1123
+ });
1124
+ this.cell.outputMetadataHeight = this._outputMetadataEditor.getContentHeight();
1125
+ this._register(this._outputMetadataEditor.onDidContentSizeChange((e) => {
1126
+ this.cell.outputMetadataHeight = e.contentHeight;
1127
+ }));
1128
+ }
1129
+ }
1130
+ this._outputViewContainer.style.display = 'block';
1131
+ }
1132
+ _decorate() {
1133
+ if (this.cell.checkIfOutputsModified()) {
1134
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Original, this.cell.original.id, ['nb-cellDeleted'], []);
1135
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Modified, this.cell.modified.id, ['nb-cellAdded'], []);
1136
+ }
1137
+ else {
1138
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Original, this.cell.original.id, [], ['nb-cellDeleted']);
1139
+ this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Modified, this.cell.modified.id, [], ['nb-cellAdded']);
1140
+ }
1141
+ }
1142
+ _showOutputsRenderer() {
1143
+ if (this._outputViewContainer) {
1144
+ this._outputViewContainer.style.display = 'block';
1145
+ this._outputLeftView?.showOutputs();
1146
+ this._outputRightView?.showOutputs();
1147
+ this._outputMetadataEditor?.layout();
1148
+ this._decorate();
1149
+ }
1150
+ }
1151
+ _hideOutputsRenderer() {
1152
+ if (this._outputViewContainer) {
1153
+ this._outputViewContainer.style.display = 'none';
1154
+ this._outputLeftView?.hideOutputs();
1155
+ this._outputRightView?.hideOutputs();
1156
+ }
1157
+ }
1158
+ updateSourceEditor() {
1159
+ const modifiedCell = this.cell.modified;
1160
+ const lineCount = modifiedCell.textModel.textBuffer.getLineCount();
1161
+ const lineHeight = this.notebookEditor.getLayoutInfo().fontInfo.lineHeight || 17;
1162
+ const editorHeight = this.cell.layoutInfo.editorHeight !== 0 ? this.cell.layoutInfo.editorHeight : lineCount * lineHeight + fixedEditorPadding.top + fixedEditorPadding.bottom;
1163
+ this._editorContainer = this.templateData.editorContainer;
1164
+ this._editor = this.templateData.sourceEditor;
1165
+ this._editorContainer.classList.add('diff');
1166
+ this._editor.layout({
1167
+ width: this.notebookEditor.getLayoutInfo().width - 2 * DIFF_CELL_MARGIN,
1168
+ height: editorHeight
1169
+ });
1170
+ this._editorContainer.style.height = `${editorHeight}px`;
1171
+ this._register(this._editor.onDidContentSizeChange((e) => {
1172
+ if (e.contentHeightChanged && this.cell.layoutInfo.editorHeight !== e.contentHeight) {
1173
+ this.cell.editorHeight = e.contentHeight;
1174
+ }
1175
+ }));
1176
+ this._initializeSourceDiffEditor();
1177
+ const scopedContextKeyService = this.contextKeyService.createScoped(this.templateData.inputToolbarContainer);
1178
+ this._register(scopedContextKeyService);
1179
+ const inputChanged = NOTEBOOK_DIFF_CELL_INPUT.bindTo(scopedContextKeyService);
1180
+ this._inputToolbarContainer = this.templateData.inputToolbarContainer;
1181
+ this._toolbar = this.templateData.toolbar;
1182
+ this._toolbar.context = {
1183
+ cell: this.cell
1184
+ };
1185
+ if (this.cell.modified.textModel.getValue() !== this.cell.original.textModel.getValue()) {
1186
+ this._inputToolbarContainer.style.display = 'block';
1187
+ inputChanged.set(true);
1188
+ }
1189
+ else {
1190
+ this._inputToolbarContainer.style.display = 'none';
1191
+ inputChanged.set(false);
1192
+ }
1193
+ this._register(this.cell.modified.textModel.onDidChangeContent(() => {
1194
+ if (this.cell.modified.textModel.getValue() !== this.cell.original.textModel.getValue()) {
1195
+ this._inputToolbarContainer.style.display = 'block';
1196
+ inputChanged.set(true);
1197
+ }
1198
+ else {
1199
+ this._inputToolbarContainer.style.display = 'none';
1200
+ inputChanged.set(false);
1201
+ }
1202
+ }));
1203
+ const menu = this.menuService.createMenu(MenuId.NotebookDiffCellInputTitle, scopedContextKeyService);
1204
+ const actions = [];
1205
+ createAndFillInActionBarActions(menu, { shouldForwardArgs: true }, actions);
1206
+ this._toolbar.setActions(actions);
1207
+ menu.dispose();
1208
+ }
1209
+ async _initializeSourceDiffEditor() {
1210
+ const originalCell = this.cell.original;
1211
+ const modifiedCell = this.cell.modified;
1212
+ const originalRef = await this.textModelService.createModelReference(originalCell.uri);
1213
+ const modifiedRef = await this.textModelService.createModelReference(modifiedCell.uri);
1214
+ if (this._isDisposed) {
1215
+ return;
1216
+ }
1217
+ const textModel = originalRef.object.textEditorModel;
1218
+ const modifiedTextModel = modifiedRef.object.textEditorModel;
1219
+ this._register(originalRef);
1220
+ this._register(modifiedRef);
1221
+ this._editor.setModel({
1222
+ original: textModel,
1223
+ modified: modifiedTextModel
1224
+ });
1225
+ const handleViewStateChange = () => {
1226
+ this._editorViewStateChanged = true;
1227
+ };
1228
+ const handleScrollChange = (e) => {
1229
+ if (e.scrollTopChanged || e.scrollLeftChanged) {
1230
+ this._editorViewStateChanged = true;
1231
+ }
1232
+ };
1233
+ this._register(this._editor.getOriginalEditor().onDidChangeCursorSelection(handleViewStateChange));
1234
+ this._register(this._editor.getOriginalEditor().onDidScrollChange(handleScrollChange));
1235
+ this._register(this._editor.getModifiedEditor().onDidChangeCursorSelection(handleViewStateChange));
1236
+ this._register(this._editor.getModifiedEditor().onDidScrollChange(handleScrollChange));
1237
+ const editorViewState = this.cell.getSourceEditorViewState();
1238
+ if (editorViewState) {
1239
+ this._editor.restoreViewState(editorViewState);
1240
+ }
1241
+ const contentHeight = this._editor.getContentHeight();
1242
+ this.cell.editorHeight = contentHeight;
1243
+ }
1244
+ layout(state) {
1245
+ dom.scheduleAtNextAnimationFrame(dom.getWindow(this._diffEditorContainer), () => {
1246
+ if (state.editorHeight) {
1247
+ this._editorContainer.style.height = `${this.cell.layoutInfo.editorHeight}px`;
1248
+ this._editor.layout({
1249
+ width: this._editor.getViewWidth(),
1250
+ height: this.cell.layoutInfo.editorHeight
1251
+ });
1252
+ }
1253
+ if (state.outerWidth) {
1254
+ this._editorContainer.style.height = `${this.cell.layoutInfo.editorHeight}px`;
1255
+ this._editor.layout();
1256
+ }
1257
+ if (state.metadataHeight || state.outerWidth) {
1258
+ if (this._metadataEditorContainer) {
1259
+ this._metadataEditorContainer.style.height = `${this.cell.layoutInfo.metadataHeight}px`;
1260
+ this._metadataEditor?.layout();
1261
+ }
1262
+ }
1263
+ if (state.outputTotalHeight || state.outerWidth) {
1264
+ if (this._outputEditorContainer) {
1265
+ this._outputEditorContainer.style.height = `${this.cell.layoutInfo.outputTotalHeight}px`;
1266
+ this._outputEditor?.layout();
1267
+ }
1268
+ if (this._outputMetadataContainer) {
1269
+ this._outputMetadataContainer.style.height = `${this.cell.layoutInfo.outputMetadataHeight}px`;
1270
+ this._outputMetadataContainer.style.top = `${this.cell.layoutInfo.outputTotalHeight - this.cell.layoutInfo.outputMetadataHeight}px`;
1271
+ this._outputMetadataEditor?.layout();
1272
+ }
1273
+ }
1274
+ this.layoutNotebookCell();
1275
+ });
1276
+ }
1277
+ dispose() {
1278
+ if (this._editor && this._editorViewStateChanged) {
1279
+ this.cell.saveSpirceEditorViewState(this._editor.saveViewState());
1280
+ }
1281
+ super.dispose();
1282
+ }
1283
+ };
1284
+ ModifiedElement = ( __decorate([
1285
+ ( __param(3, IInstantiationService)),
1286
+ ( __param(4, ILanguageService)),
1287
+ ( __param(5, IModelService)),
1288
+ ( __param(6, ITextModelService)),
1289
+ ( __param(7, IContextMenuService)),
1290
+ ( __param(8, IKeybindingService)),
1291
+ ( __param(9, INotificationService)),
1292
+ ( __param(10, IMenuService)),
1293
+ ( __param(11, IContextKeyService)),
1294
+ ( __param(12, IConfigurationService))
1295
+ ], ModifiedElement));
1296
+
1297
+ export { DeletedElement, InsertElement, ModifiedElement, getOptimizedNestedCodeEditorWidgetOptions };