@codingame/monaco-vscode-notebook-service-override 13.1.7 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/index.js +3 -3
  2. package/package.json +29 -28
  3. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +8 -8
  4. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +25 -24
  5. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.d.ts +1 -1
  6. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +2 -2
  7. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +6 -6
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.d.ts +1 -1
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +2 -2
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.d.ts +1 -1
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +1 -1
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +4 -4
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookCellDecorators.d.ts +60 -0
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookCellDecorators.js +536 -0
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.d.ts +24 -0
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.js +310 -0
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatEditController.d.ts +9 -0
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatEditController.js +182 -0
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.d.ts +21 -0
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.js +42 -0
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalModelRefFactory.d.ts +23 -0
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalModelRefFactory.js +72 -0
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizer.d.ts +62 -0
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizer.js +425 -0
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizerService.d.ts +1 -1
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizerService.js +0 -1
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.d.ts +2 -2
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +9 -9
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +1 -1
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.d.ts +1 -1
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +3 -3
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +1 -1
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +11 -11
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.d.ts +1 -1
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +1 -1
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +5 -5
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +6 -6
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +4 -4
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +1 -1
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +2 -2
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.d.ts +1 -1
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +9 -9
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookSelectionHighlight.js +2 -1
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +15 -15
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.d.ts +29 -0
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.js +310 -0
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +2 -2
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +1 -1
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +2 -2
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +4 -4
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.d.ts +4 -3
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +35 -25
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +1 -1
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +14 -14
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.d.ts +1 -1
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +5 -5
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +1 -1
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +3 -3
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.d.ts +1 -1
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +32 -32
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +3 -3
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +29 -26
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +25 -25
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +25 -25
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +19 -19
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +8 -8
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.d.ts +1 -1
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +14 -14
  69. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.js +2 -2
  70. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +21 -21
  71. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +92 -74
  72. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.d.ts +2 -2
  73. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +11 -11
  74. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.d.ts +2 -2
  75. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +2 -2
  76. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +33 -33
  77. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.d.ts +2 -2
  78. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +2 -2
  79. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.d.ts +1 -1
  80. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +1 -1
  81. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.d.ts +1 -1
  82. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +1 -1
  83. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +1 -1
  84. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +4 -4
  85. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +2 -1
  86. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.d.ts +3 -3
  87. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +5 -5
  88. package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.d.ts +1 -1
  89. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.d.ts +1 -1
  90. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.d.ts +1 -1
  91. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +3 -3
  92. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +1 -1
  93. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.d.ts +1 -1
  94. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.d.ts +1 -1
  95. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +16 -13
  96. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +5 -3
  97. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.d.ts +2 -2
  98. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +2 -2
  99. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.d.ts +9 -0
  100. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +5 -0
@@ -0,0 +1,536 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { DisposableStore, toDisposable, Disposable, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
4
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
5
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
6
+ import { autorunWithStore, autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
7
+ import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/derived';
8
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
9
+ import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils';
10
+ import { ChatEditingSessionState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
11
+ import { IChatEditingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService.service';
12
+ import { ThrottledDelayer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
13
+ import { IEditorWorkerService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/editorWorker';
14
+ import { ILanguageService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language';
15
+ import { EditorOption } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/config/editorOptions';
16
+ import { themeColorFromId } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
17
+ import { RenderOptions, LineSource, renderLines } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/diffEditor/components/diffEditorViewZones/renderLines';
18
+ import { diffAddDecoration, diffWholeLineAddDecoration, diffDeleteDecoration } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/diffEditor/registrations.contribution';
19
+ import { TrackedRangeStickiness, MinimapPosition, OverviewRulerLane } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model';
20
+ import { ModelDecorationOptions } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModel';
21
+ import { InlineDecoration, InlineDecorationType } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/viewModel';
22
+ import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
23
+ import { tokenizeToString } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/textToHtmlTokenizer';
24
+ import { append, $ } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
25
+ import { createTrustedTypesPolicy } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/trustedTypes';
26
+ import { splitLines } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
27
+ import { DefaultLineHeight } from '@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel';
28
+ import { INotebookOriginalCellModelFactory } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.service';
29
+ import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
30
+ import { overviewRulerModifiedForeground, minimapGutterModifiedBackground, overviewRulerAddedForeground, minimapGutterAddedBackground, overviewRulerDeletedForeground, minimapGutterDeletedBackground } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/quickDiff';
31
+
32
+ let NotebookCellDiffDecorator = class NotebookCellDiffDecorator extends DisposableStore {
33
+ constructor(notebookEditor, modifiedCell, originalCell, _chatEditingService, _editorWorkerService, originalCellModelFactory) {
34
+ super();
35
+ this.modifiedCell = modifiedCell;
36
+ this.originalCell = originalCell;
37
+ this._chatEditingService = _chatEditingService;
38
+ this._editorWorkerService = _editorWorkerService;
39
+ this.originalCellModelFactory = originalCellModelFactory;
40
+ this._viewZones = [];
41
+ this.throttledDecorator = ( new ThrottledDelayer(50));
42
+ this.perEditorDisposables = this.add(( new DisposableStore()));
43
+ const onDidChangeVisibleRanges = observableFromEvent(notebookEditor.onDidChangeVisibleRanges, () => notebookEditor.visibleRanges);
44
+ const editorObs = derived((r) => {
45
+ const visibleRanges = onDidChangeVisibleRanges.read(r);
46
+ const visibleCellHandles = ( ( visibleRanges.map(range => notebookEditor.getCellsInRange(range))).flat().map(c => c.handle));
47
+ if (!visibleCellHandles.includes(modifiedCell.handle)) {
48
+ return;
49
+ }
50
+ const editor = notebookEditor.codeEditors.find(item => item[0].handle === modifiedCell.handle)?.[1];
51
+ if (editor?.getModel() !== this.modifiedCell.textModel) {
52
+ return;
53
+ }
54
+ return editor;
55
+ });
56
+ this.add(autorunWithStore((r, store) => {
57
+ const editor = editorObs.read(r);
58
+ this.perEditorDisposables.clear();
59
+ if (editor) {
60
+ store.add(editor.onDidChangeModel(() => {
61
+ this.perEditorDisposables.clear();
62
+ }));
63
+ store.add(editor.onDidChangeModelContent(() => {
64
+ this.update(editor);
65
+ }));
66
+ store.add(editor.onDidChangeConfiguration((e) => {
67
+ if (e.hasChanged(EditorOption.fontInfo) || e.hasChanged(EditorOption.lineHeight)) {
68
+ this.update(editor);
69
+ }
70
+ }));
71
+ this.update(editor);
72
+ }
73
+ }));
74
+ const shouldBeReadOnly = derived(this, r => {
75
+ const editor = editorObs.read(r);
76
+ if (!editor) {
77
+ return false;
78
+ }
79
+ const value = this._chatEditingService.currentEditingSessionObs.read(r);
80
+ if (!value || value.state.read(r) !== ChatEditingSessionState.StreamingEdits) {
81
+ return false;
82
+ }
83
+ return ( value.entries.read(r).some(e => isEqual(e.modifiedURI, editor.getModel()?.uri)));
84
+ });
85
+ let actualReadonly;
86
+ let actualDeco;
87
+ this.add(autorun((r) => {
88
+ const editor = editorObs.read(r);
89
+ if (!editor) {
90
+ return;
91
+ }
92
+ const value = shouldBeReadOnly.read(r);
93
+ if (value) {
94
+ actualReadonly ??= editor.getOption(EditorOption.readOnly);
95
+ actualDeco ??= editor.getOption(EditorOption.renderValidationDecorations);
96
+ editor.updateOptions({
97
+ readOnly: true,
98
+ renderValidationDecorations: 'off'
99
+ });
100
+ }
101
+ else {
102
+ if (actualReadonly !== undefined && actualDeco !== undefined) {
103
+ editor.updateOptions({
104
+ readOnly: actualReadonly,
105
+ renderValidationDecorations: actualDeco
106
+ });
107
+ actualReadonly = undefined;
108
+ actualDeco = undefined;
109
+ }
110
+ }
111
+ }));
112
+ }
113
+ update(editor) {
114
+ this.throttledDecorator.trigger(() => this._updateImpl(editor));
115
+ }
116
+ async _updateImpl(editor) {
117
+ if (this.isDisposed) {
118
+ return;
119
+ }
120
+ if (editor.getOption(EditorOption.inDiffEditor)) {
121
+ this.perEditorDisposables.clear();
122
+ return;
123
+ }
124
+ const model = editor.getModel();
125
+ if (!model || model !== this.modifiedCell.textModel) {
126
+ this.perEditorDisposables.clear();
127
+ return;
128
+ }
129
+ const originalModel = this.getOrCreateOriginalModel(editor);
130
+ if (!originalModel) {
131
+ this.perEditorDisposables.clear();
132
+ return;
133
+ }
134
+ const version = model.getVersionId();
135
+ const diff = await this._editorWorkerService.computeDiff(originalModel.uri, model.uri, { computeMoves: true, ignoreTrimWhitespace: false, maxComputationTimeMs: Number.MAX_SAFE_INTEGER }, 'advanced');
136
+ if (this.isDisposed) {
137
+ return;
138
+ }
139
+ if (diff && !diff.identical && originalModel && model === editor.getModel() && editor.getModel()?.getVersionId() === version) {
140
+ this._updateWithDiff(editor, originalModel, diff);
141
+ }
142
+ else {
143
+ this.perEditorDisposables.clear();
144
+ }
145
+ }
146
+ getOrCreateOriginalModel(editor) {
147
+ if (!this._originalModel) {
148
+ const model = editor.getModel();
149
+ if (!model) {
150
+ return;
151
+ }
152
+ this._originalModel = this.add(this.originalCellModelFactory.getOrCreate(model.uri, this.originalCell.getValue(), model.getLanguageId(), this.modifiedCell.cellKind)).object;
153
+ }
154
+ return this._originalModel;
155
+ }
156
+ _updateWithDiff(editor, originalModel, diff) {
157
+ if (areDiffsEqual(diff, this.diffForPreviouslyAppliedDecorators)) {
158
+ return;
159
+ }
160
+ this.perEditorDisposables.clear();
161
+ const decorations = editor.createDecorationsCollection();
162
+ this.perEditorDisposables.add(toDisposable(() => {
163
+ editor.changeViewZones((viewZoneChangeAccessor) => {
164
+ for (const id of this._viewZones) {
165
+ viewZoneChangeAccessor.removeZone(id);
166
+ }
167
+ });
168
+ this._viewZones = [];
169
+ decorations.clear();
170
+ this.diffForPreviouslyAppliedDecorators = undefined;
171
+ }));
172
+ this.diffForPreviouslyAppliedDecorators = diff;
173
+ const chatDiffAddDecoration = ModelDecorationOptions.createDynamic({
174
+ ...diffAddDecoration,
175
+ stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
176
+ });
177
+ const chatDiffWholeLineAddDecoration = ModelDecorationOptions.createDynamic({
178
+ ...diffWholeLineAddDecoration,
179
+ stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
180
+ });
181
+ const createOverviewDecoration = (overviewRulerColor, minimapColor) => {
182
+ return ModelDecorationOptions.createDynamic({
183
+ description: 'chat-editing-decoration',
184
+ overviewRuler: { color: themeColorFromId(overviewRulerColor), position: OverviewRulerLane.Left },
185
+ minimap: { color: themeColorFromId(minimapColor), position: MinimapPosition.Gutter },
186
+ });
187
+ };
188
+ const modifiedDecoration = createOverviewDecoration(overviewRulerModifiedForeground, minimapGutterModifiedBackground);
189
+ const addedDecoration = createOverviewDecoration(overviewRulerAddedForeground, minimapGutterAddedBackground);
190
+ const deletedDecoration = createOverviewDecoration(overviewRulerDeletedForeground, minimapGutterDeletedBackground);
191
+ editor.changeViewZones((viewZoneChangeAccessor) => {
192
+ for (const id of this._viewZones) {
193
+ viewZoneChangeAccessor.removeZone(id);
194
+ }
195
+ this._viewZones = [];
196
+ const modifiedDecorations = [];
197
+ const mightContainNonBasicASCII = originalModel?.mightContainNonBasicASCII();
198
+ const mightContainRTL = originalModel?.mightContainRTL();
199
+ const renderOptions = RenderOptions.fromEditor(editor);
200
+ for (const diffEntry of diff.changes) {
201
+ const originalRange = diffEntry.original;
202
+ if (originalModel) {
203
+ originalModel.tokenization.forceTokenization(Math.max(1, originalRange.endLineNumberExclusive - 1));
204
+ }
205
+ const source = ( new LineSource(
206
+ (originalRange.length && originalModel) ? originalRange.mapToLineArray(l => originalModel.tokenization.getLineTokens(l)) : [],
207
+ [],
208
+ mightContainNonBasicASCII,
209
+ mightContainRTL
210
+ ));
211
+ const decorations = [];
212
+ for (const i of diffEntry.innerChanges || []) {
213
+ decorations.push(( new InlineDecoration(
214
+ i.originalRange.delta(-(diffEntry.original.startLineNumber - 1)),
215
+ diffDeleteDecoration.className,
216
+ InlineDecorationType.Regular
217
+ )));
218
+ modifiedDecorations.push({
219
+ range: i.modifiedRange, options: chatDiffAddDecoration
220
+ });
221
+ }
222
+ if (!diffEntry.modified.isEmpty) {
223
+ modifiedDecorations.push({
224
+ range: diffEntry.modified.toInclusiveRange(), options: chatDiffWholeLineAddDecoration
225
+ });
226
+ }
227
+ if (diffEntry.original.isEmpty) {
228
+ modifiedDecorations.push({
229
+ range: diffEntry.modified.toInclusiveRange(),
230
+ options: addedDecoration
231
+ });
232
+ }
233
+ else if (diffEntry.modified.isEmpty) {
234
+ modifiedDecorations.push({
235
+ range: ( new Range(
236
+ diffEntry.modified.startLineNumber - 1,
237
+ 1,
238
+ diffEntry.modified.startLineNumber,
239
+ 1
240
+ )),
241
+ options: deletedDecoration
242
+ });
243
+ }
244
+ else {
245
+ modifiedDecorations.push({
246
+ range: diffEntry.modified.toInclusiveRange(),
247
+ options: modifiedDecoration
248
+ });
249
+ }
250
+ const domNode = document.createElement('div');
251
+ domNode.className = 'chat-editing-original-zone view-lines line-delete monaco-mouse-cursor-text';
252
+ const result = renderLines(source, renderOptions, decorations, domNode);
253
+ const isCreatedContent = decorations.length === 1 && decorations[0].range.isEmpty() && decorations[0].range.startLineNumber === 1;
254
+ if (!isCreatedContent) {
255
+ const viewZoneData = {
256
+ afterLineNumber: diffEntry.modified.startLineNumber - 1,
257
+ heightInLines: result.heightInLines,
258
+ domNode,
259
+ ordinal: 50000 + 2
260
+ };
261
+ this._viewZones.push(viewZoneChangeAccessor.addZone(viewZoneData));
262
+ }
263
+ }
264
+ decorations.set(modifiedDecorations);
265
+ });
266
+ }
267
+ };
268
+ NotebookCellDiffDecorator = ( __decorate([
269
+ ( __param(3, IChatEditingService)),
270
+ ( __param(4, IEditorWorkerService)),
271
+ ( __param(5, INotebookOriginalCellModelFactory))
272
+ ], NotebookCellDiffDecorator));
273
+ class NotebookInsertedCellDecorator extends Disposable {
274
+ constructor(notebookEditor) {
275
+ super();
276
+ this.notebookEditor = notebookEditor;
277
+ this.decorators = this._register(( new DisposableStore()));
278
+ }
279
+ apply(diffInfo) {
280
+ const model = this.notebookEditor.textModel;
281
+ if (!model) {
282
+ return;
283
+ }
284
+ const cells = ( diffInfo.filter(diff => diff.type === 'insert').map((diff) => model.cells[diff.modifiedCellIndex]));
285
+ const ids = this.notebookEditor.deltaCellDecorations([], ( cells.map(cell => ({
286
+ handle: cell.handle,
287
+ options: { className: 'nb-insertHighlight', outputClassName: 'nb-insertHighlight' }
288
+ }))));
289
+ this.clear();
290
+ this.decorators.add(toDisposable(() => {
291
+ if (!this.notebookEditor.isDisposed) {
292
+ this.notebookEditor.deltaCellDecorations(ids, []);
293
+ }
294
+ }));
295
+ }
296
+ clear() {
297
+ this.decorators.clear();
298
+ }
299
+ }
300
+ const ttPolicy = createTrustedTypesPolicy('notebookChatEditController', { createHTML: value => value });
301
+ let NotebookDeletedCellDecorator = class NotebookDeletedCellDecorator extends Disposable {
302
+ constructor(_notebookEditor, languageService) {
303
+ super();
304
+ this._notebookEditor = _notebookEditor;
305
+ this.languageService = languageService;
306
+ this.zoneRemover = this._register(( new DisposableStore()));
307
+ this.createdViewZones = ( new Map());
308
+ this.deletedCellInfos = ( new Map());
309
+ }
310
+ getTop(deletedIndex) {
311
+ const info = this.deletedCellInfos.get(deletedIndex);
312
+ if (!info) {
313
+ return;
314
+ }
315
+ const cells = this._notebookEditor.getCellsInRange({ start: info.previousIndex, end: info.previousIndex + 1 });
316
+ if (!cells.length) {
317
+ return;
318
+ }
319
+ const cell = cells[0];
320
+ const cellHeight = this._notebookEditor.getHeightOfElement(cell);
321
+ const top = this._notebookEditor.getAbsoluteTopOfElement(cell);
322
+ return top + cellHeight + info.offset;
323
+ }
324
+ apply(diffInfo, original) {
325
+ this.clear();
326
+ let currentIndex = 0;
327
+ const deletedCellsToRender = { cells: [], index: 0 };
328
+ diffInfo.forEach(diff => {
329
+ if (diff.type === 'delete') {
330
+ const deletedCell = original.cells[diff.originalCellIndex];
331
+ if (deletedCell) {
332
+ deletedCellsToRender.cells.push({ cell: deletedCell, originalIndex: diff.originalCellIndex, previousIndex: currentIndex });
333
+ deletedCellsToRender.index = currentIndex;
334
+ }
335
+ }
336
+ else {
337
+ if (deletedCellsToRender.cells.length) {
338
+ this._createWidget(deletedCellsToRender.index + 1, deletedCellsToRender.cells);
339
+ deletedCellsToRender.cells.length = 0;
340
+ }
341
+ currentIndex = diff.modifiedCellIndex;
342
+ }
343
+ });
344
+ if (deletedCellsToRender.cells.length) {
345
+ this._createWidget(deletedCellsToRender.index + 1, deletedCellsToRender.cells);
346
+ }
347
+ }
348
+ clear() {
349
+ this.deletedCellInfos.clear();
350
+ this.zoneRemover.clear();
351
+ }
352
+ _createWidget(index, cells) {
353
+ this._createWidgetImpl(index, cells);
354
+ }
355
+ async _createWidgetImpl(index, cells) {
356
+ const rootContainer = document.createElement('div');
357
+ const widgets = [];
358
+ const heights = await Promise.all(( cells.map(async (cell) => {
359
+ const widget = ( new NotebookDeletedCellWidget(
360
+ this._notebookEditor,
361
+ cell.cell.getValue(),
362
+ cell.cell.language,
363
+ rootContainer,
364
+ cell.originalIndex,
365
+ this.languageService
366
+ ));
367
+ widgets.push(widget);
368
+ const height = await widget.render();
369
+ this.deletedCellInfos.set(cell.originalIndex, { height, previousIndex: cell.previousIndex, offset: 0 });
370
+ return height;
371
+ })));
372
+ Array.from(( this.deletedCellInfos.keys())).sort((a, b) => a - b).forEach((originalIndex) => {
373
+ const previousDeletedCell = this.deletedCellInfos.get(originalIndex - 1);
374
+ if (previousDeletedCell) {
375
+ const deletedCell = this.deletedCellInfos.get(originalIndex);
376
+ if (deletedCell) {
377
+ deletedCell.offset = previousDeletedCell.height + previousDeletedCell.offset;
378
+ }
379
+ }
380
+ });
381
+ const totalHeight = heights.reduce((prev, curr) => prev + curr, 0);
382
+ this._notebookEditor.changeViewZones(accessor => {
383
+ const notebookViewZone = {
384
+ afterModelPosition: index,
385
+ heightInPx: totalHeight + 4,
386
+ domNode: rootContainer
387
+ };
388
+ const id = accessor.addZone(notebookViewZone);
389
+ accessor.layoutZone(id);
390
+ this.createdViewZones.set(index, id);
391
+ this.zoneRemover.add(toDisposable(() => {
392
+ if (this.createdViewZones.get(index) === id) {
393
+ this.createdViewZones.delete(index);
394
+ }
395
+ if (!this._notebookEditor.isDisposed) {
396
+ this._notebookEditor.changeViewZones(accessor => {
397
+ accessor.removeZone(id);
398
+ dispose(widgets);
399
+ });
400
+ }
401
+ }));
402
+ });
403
+ }
404
+ };
405
+ NotebookDeletedCellDecorator = ( __decorate([
406
+ ( __param(1, ILanguageService))
407
+ ], NotebookDeletedCellDecorator));
408
+ let NotebookDeletedCellWidget = class NotebookDeletedCellWidget extends Disposable {
409
+ constructor(_notebookEditor,
410
+ code, language, container, originalIndex, languageService) {
411
+ super();
412
+ this._notebookEditor = _notebookEditor;
413
+ this.code = code;
414
+ this.language = language;
415
+ this.originalIndex = originalIndex;
416
+ this.languageService = languageService;
417
+ this.container = append(container, document.createElement('div'));
418
+ this._register(toDisposable(() => {
419
+ container.removeChild(this.container);
420
+ }));
421
+ }
422
+ async render() {
423
+ const code = this.code;
424
+ const languageId = this.language;
425
+ const codeHtml = await tokenizeToString(this.languageService, code, languageId);
426
+ const fontInfo = this._notebookEditor.getBaseCellEditorOptions(languageId).value;
427
+ const fontFamilyVar = '--notebook-editor-font-family';
428
+ const fontSizeVar = '--notebook-editor-font-size';
429
+ const fontWeightVar = '--notebook-editor-font-weight';
430
+ const editor = ( this._notebookEditor.codeEditors.map(c => c[1])).find(c => c);
431
+ const layoutInfo = editor?.getOptions().get(EditorOption.layoutInfo);
432
+ const style = ``
433
+ + `font-family: var(${fontFamilyVar});`
434
+ + `font-weight: var(${fontWeightVar});`
435
+ + `font-size: var(${fontSizeVar});`
436
+ + fontInfo.lineHeight ? `line-height: ${fontInfo.lineHeight}px;` : ''
437
+ + layoutInfo?.contentLeft ? `margin-left: ${layoutInfo}px;` : ''
438
+ + `white-space: pre;`;
439
+ const rootContainer = this.container;
440
+ rootContainer.classList.add('code-cell-row');
441
+ const container = append(rootContainer, $('.cell-inner-container'));
442
+ const focusIndicatorLeft = append(container, $('.cell-focus-indicator.cell-focus-indicator-side.cell-focus-indicator-left'));
443
+ const cellContainer = append(container, $('.cell.code'));
444
+ append(focusIndicatorLeft, $('div.execution-count-label'));
445
+ const editorPart = append(cellContainer, $('.cell-editor-part'));
446
+ let editorContainer = append(editorPart, $('.cell-editor-container'));
447
+ editorContainer = append(editorContainer, $('.code', { style }));
448
+ if (fontInfo.fontFamily) {
449
+ editorContainer.style.setProperty(fontFamilyVar, fontInfo.fontFamily);
450
+ }
451
+ if (fontInfo.fontSize) {
452
+ editorContainer.style.setProperty(fontSizeVar, `${fontInfo.fontSize}px`);
453
+ }
454
+ if (fontInfo.fontWeight) {
455
+ editorContainer.style.setProperty(fontWeightVar, fontInfo.fontWeight);
456
+ }
457
+ editorContainer.innerHTML = (ttPolicy?.createHTML(codeHtml) || codeHtml);
458
+ const lineCount = splitLines(code).length;
459
+ const height = (lineCount * (fontInfo.lineHeight || DefaultLineHeight)) + 12 + 12;
460
+ const totalHeight = height + 16 + 16;
461
+ return totalHeight;
462
+ }
463
+ };
464
+ NotebookDeletedCellWidget = ( __decorate([
465
+ ( __param(5, ILanguageService))
466
+ ], NotebookDeletedCellWidget));
467
+ function areDiffsEqual(a, b) {
468
+ if (a && b) {
469
+ if (a.changes.length !== b.changes.length) {
470
+ return false;
471
+ }
472
+ if (a.moves.length !== b.moves.length) {
473
+ return false;
474
+ }
475
+ if (!areLineRangeMappinsEqual(a.changes, b.changes)) {
476
+ return false;
477
+ }
478
+ if (!( a.moves.some((move, i) => {
479
+ const bMove = b.moves[i];
480
+ if (!areLineRangeMappinsEqual(move.changes, bMove.changes)) {
481
+ return true;
482
+ }
483
+ if (move.lineRangeMapping.changedLineCount !== bMove.lineRangeMapping.changedLineCount) {
484
+ return true;
485
+ }
486
+ if (!move.lineRangeMapping.modified.equals(bMove.lineRangeMapping.modified)) {
487
+ return true;
488
+ }
489
+ if (!move.lineRangeMapping.original.equals(bMove.lineRangeMapping.original)) {
490
+ return true;
491
+ }
492
+ return false;
493
+ }))) {
494
+ return false;
495
+ }
496
+ return true;
497
+ }
498
+ else if (!a && !b) {
499
+ return true;
500
+ }
501
+ else {
502
+ return false;
503
+ }
504
+ }
505
+ function areLineRangeMappinsEqual(a, b) {
506
+ if (a.length !== b.length) {
507
+ return false;
508
+ }
509
+ if (( a.some((c, i) => {
510
+ const bChange = b[i];
511
+ if (c.changedLineCount !== bChange.changedLineCount) {
512
+ return true;
513
+ }
514
+ if ((c.innerChanges || []).length !== (bChange.innerChanges || []).length) {
515
+ return true;
516
+ }
517
+ if (( (c.innerChanges || []).some((innerC, innerIdx) => {
518
+ const bInnerC = bChange.innerChanges[innerIdx];
519
+ if (!innerC.modifiedRange.equalsRange(bInnerC.modifiedRange)) {
520
+ return true;
521
+ }
522
+ if (!innerC.originalRange.equalsRange(bInnerC.originalRange)) {
523
+ return true;
524
+ }
525
+ return false;
526
+ }))) {
527
+ return true;
528
+ }
529
+ return false;
530
+ }))) {
531
+ return false;
532
+ }
533
+ return true;
534
+ }
535
+
536
+ export { NotebookCellDiffDecorator, NotebookDeletedCellDecorator, NotebookDeletedCellWidget, NotebookInsertedCellDecorator };
@@ -0,0 +1,24 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { INotebookEditor } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser";
3
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
4
+ import { IModifiedFileEntry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService";
5
+ import { IChatEditingService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService.service";
6
+ import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
7
+ import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
8
+ import { CellDiffInfo } from "@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel";
9
+ import { INotebookDeletedCellDecorator } from "./notebookCellDecorators.js";
10
+ export declare class NotebookChatActionsOverlayController extends Disposable {
11
+ private readonly notebookEditor;
12
+ private readonly _chatEditingService;
13
+ constructor(notebookEditor: INotebookEditor, cellDiffInfo: IObservable<CellDiffInfo[] | undefined>, deletedCellDecorator: INotebookDeletedCellDecorator, _chatEditingService: IChatEditingService, instantiationService: IInstantiationService);
14
+ }
15
+ export declare class NotebookChatActionsOverlay extends Disposable {
16
+ private readonly notebookEditor;
17
+ private readonly _editorService;
18
+ private readonly focusedDiff;
19
+ private readonly toolbarNode;
20
+ private added;
21
+ constructor(notebookEditor: INotebookEditor, entry: IModifiedFileEntry, cellDiffInfo: IObservable<CellDiffInfo[] | undefined>, nextEntry: IModifiedFileEntry, previousEntry: IModifiedFileEntry, deletedCellDecorator: INotebookDeletedCellDecorator, _editorService: IEditorService, instaService: IInstantiationService);
22
+ private show;
23
+ private hide;
24
+ }