@codingame/monaco-vscode-api 33.0.3 → 33.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/package.json +9 -9
  2. package/services.js +3 -3
  3. package/vscode/src/vs/platform/product/common/product.js +1 -1
  4. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.d.ts +0 -26
  5. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +0 -746
  6. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.d.ts +0 -13
  7. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -300
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.d.ts +0 -8
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -55
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.d.ts +0 -273
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1963
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.d.ts +0 -50
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -314
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.d.ts +0 -258
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -886
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.d.ts +0 -41
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -118
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.d.ts +0 -17
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.js +0 -71
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.d.ts +0 -27
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -40
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.d.ts +0 -23
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.js +0 -313
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.d.ts +0 -51
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.js +0 -265
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.d.ts +0 -24
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.js +0 -185
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.d.ts +0 -28
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.js +0 -104
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.d.ts +0 -10
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.js +0 -43
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.d.ts +0 -21
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.js +0 -41
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.d.ts +0 -25
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.js +0 -69
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css +0 -469
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.d.ts +0 -149
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -933
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.d.ts +0 -180
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -32
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.d.ts +0 -102
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -643
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.d.ts +0 -30
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -197
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.d.ts +0 -75
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.js +0 -539
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.d.ts +0 -13
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.js +0 -39
  49. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.d.ts +0 -19
  50. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.js +0 -90
  51. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.d.ts +0 -26
  52. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.js +0 -92
@@ -1,51 +0,0 @@
1
- import { Disposable } from "../../../../../../base/common/lifecycle.js";
2
- import { ILanguageService } from "../../../../../../editor/common/languages/language.service.js";
3
- import { NotebookTextModel } from "@codingame/monaco-vscode-notebook-service-override/vscode/vs/workbench/contrib/notebook/common/model/notebookTextModel";
4
- import { CellDiffInfo } from "../notebookDiffViewModel.js";
5
- import { INotebookEditor } from "../../notebookBrowser.js";
6
- import { MenuId } from "../../../../../../platform/actions/common/actions.js";
7
- import { IInstantiationService } from "../../../../../../platform/instantiation/common/instantiation.js";
8
- import { IActionViewItemProvider } from "../../../../../../base/browser/ui/actionbar/actionbar.js";
9
- export interface INotebookDeletedCellDecorator {
10
- getTop(deletedIndex: number): number | undefined;
11
- }
12
- export declare class NotebookDeletedCellDecorator extends Disposable implements INotebookDeletedCellDecorator {
13
- private readonly _notebookEditor;
14
- private readonly toolbar;
15
- private readonly languageService;
16
- private readonly instantiationService;
17
- private readonly zoneRemover;
18
- private readonly createdViewZones;
19
- private readonly deletedCellInfos;
20
- constructor(_notebookEditor: INotebookEditor, toolbar: {
21
- menuId: MenuId;
22
- className: string;
23
- telemetrySource?: string;
24
- argFactory: (deletedCellIndex: number) => any;
25
- actionViewItemProvider?: IActionViewItemProvider;
26
- } | undefined, languageService: ILanguageService, instantiationService: IInstantiationService);
27
- getTop(deletedIndex: number): number | undefined;
28
- reveal(deletedIndex: number): void;
29
- apply(diffInfo: CellDiffInfo[], original: NotebookTextModel): void;
30
- clear(): void;
31
- private _createWidget;
32
- private _createWidgetImpl;
33
- }
34
- export declare class NotebookDeletedCellWidget extends Disposable {
35
- private readonly _notebookEditor;
36
- private readonly _toolbarOptions;
37
- private readonly code;
38
- private readonly language;
39
- private readonly _originalIndex;
40
- private readonly languageService;
41
- private readonly instantiationService;
42
- private readonly container;
43
- constructor(_notebookEditor: INotebookEditor, _toolbarOptions: {
44
- menuId: MenuId;
45
- className: string;
46
- telemetrySource?: string;
47
- argFactory: (deletedCellIndex: number) => any;
48
- actionViewItemProvider?: IActionViewItemProvider;
49
- } | undefined, code: string, language: string, container: HTMLElement, _originalIndex: number, languageService: ILanguageService, instantiationService: IInstantiationService);
50
- render(): Promise<number>;
51
- }
@@ -1,265 +0,0 @@
1
-
2
- import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
3
- import { createTrustedTypesPolicy } from '../../../../../../base/browser/trustedTypes.js';
4
- import { Disposable, DisposableStore, toDisposable, dispose } from '../../../../../../base/common/lifecycle.js';
5
- import { splitLines } from '../../../../../../base/common/strings.js';
6
- import { EditorOption } from '../../../../../../editor/common/config/editorOptions.js';
7
- import { ILanguageService } from '../../../../../../editor/common/languages/language.service.js';
8
- import { tokenizeToString } from '../../../../../../editor/common/languages/textToHtmlTokenizer.js';
9
- import { DefaultLineHeight } from '../diffElementViewModel.js';
10
- import { NotebookOverviewRulerLane } from '../../notebookBrowser.js';
11
- import { createElement, append, $ } from '../../../../../../base/browser/dom.js';
12
- import { MenuWorkbenchToolBar, HiddenItemStrategy } from '../../../../../../platform/actions/browser/toolbar.js';
13
- import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
14
- import { ServiceCollection } from '../../../../../../platform/instantiation/common/serviceCollection.js';
15
- import { IContextKeyService } from '../../../../../../platform/contextkey/common/contextkey.service.js';
16
- import { overviewRulerDeletedForeground } from '../../../../scm/common/quickDiff.js';
17
-
18
- const ttPolicy = createTrustedTypesPolicy("notebookRenderer", {
19
- createHTML: value => value
20
- });
21
- let NotebookDeletedCellDecorator = class NotebookDeletedCellDecorator extends Disposable {
22
- constructor(_notebookEditor, toolbar, languageService, instantiationService) {
23
- super();
24
- this._notebookEditor = _notebookEditor;
25
- this.toolbar = toolbar;
26
- this.languageService = languageService;
27
- this.instantiationService = instantiationService;
28
- this.zoneRemover = this._register(( new DisposableStore()));
29
- this.createdViewZones = ( new Map());
30
- this.deletedCellInfos = ( new Map());
31
- }
32
- getTop(deletedIndex) {
33
- const info = this.deletedCellInfos.get(deletedIndex);
34
- if (!info) {
35
- return;
36
- }
37
- if (info.previousIndex === -1) {
38
- return 0;
39
- }
40
- const cells = this._notebookEditor.getCellsInRange({
41
- start: info.previousIndex,
42
- end: info.previousIndex + 1
43
- });
44
- if (!cells.length) {
45
- return this._notebookEditor.getLayoutInfo().height + info.offset;
46
- }
47
- const cell = cells[0];
48
- const cellHeight = this._notebookEditor.getHeightOfElement(cell);
49
- const top = this._notebookEditor.getAbsoluteTopOfElement(cell);
50
- return top + cellHeight + info.offset;
51
- }
52
- reveal(deletedIndex) {
53
- const top = this.getTop(deletedIndex);
54
- if (typeof top === "number") {
55
- this._notebookEditor.focusContainer();
56
- this._notebookEditor.revealOffsetInCenterIfOutsideViewport(top);
57
- const info = this.deletedCellInfos.get(deletedIndex);
58
- if (info) {
59
- const prevIndex = info.previousIndex === -1 ? 0 : info.previousIndex;
60
- this._notebookEditor.setFocus({
61
- start: prevIndex,
62
- end: prevIndex
63
- });
64
- this._notebookEditor.setSelections([{
65
- start: prevIndex,
66
- end: prevIndex
67
- }]);
68
- }
69
- }
70
- }
71
- apply(diffInfo, original) {
72
- this.clear();
73
- let currentIndex = -1;
74
- const deletedCellsToRender = {
75
- cells: [],
76
- index: 0
77
- };
78
- diffInfo.forEach(diff => {
79
- if (diff.type === "delete") {
80
- const deletedCell = original.cells[diff.originalCellIndex];
81
- if (deletedCell) {
82
- deletedCellsToRender.cells.push({
83
- cell: deletedCell,
84
- originalIndex: diff.originalCellIndex,
85
- previousIndex: currentIndex
86
- });
87
- deletedCellsToRender.index = currentIndex;
88
- }
89
- } else {
90
- if (deletedCellsToRender.cells.length) {
91
- this._createWidget(deletedCellsToRender.index + 1, deletedCellsToRender.cells);
92
- deletedCellsToRender.cells.length = 0;
93
- }
94
- currentIndex = diff.modifiedCellIndex;
95
- }
96
- });
97
- if (deletedCellsToRender.cells.length) {
98
- this._createWidget(deletedCellsToRender.index + 1, deletedCellsToRender.cells);
99
- }
100
- }
101
- clear() {
102
- this.deletedCellInfos.clear();
103
- this.zoneRemover.clear();
104
- }
105
- _createWidget(index, cells) {
106
- this._createWidgetImpl(index, cells);
107
- }
108
- async _createWidgetImpl(index, cells) {
109
- const rootContainer = createElement("div");
110
- const widgets = [];
111
- const heights = await Promise.all(( cells.map(async cell => {
112
- const widget = ( new NotebookDeletedCellWidget(
113
- this._notebookEditor,
114
- this.toolbar,
115
- cell.cell.getValue(),
116
- cell.cell.language,
117
- rootContainer,
118
- cell.originalIndex,
119
- this.languageService,
120
- this.instantiationService
121
- ));
122
- widgets.push(widget);
123
- const height = await widget.render();
124
- this.deletedCellInfos.set(cell.originalIndex, {
125
- height,
126
- previousIndex: cell.previousIndex,
127
- offset: 0
128
- });
129
- return height;
130
- })));
131
- Array.from(( this.deletedCellInfos.keys())).sort((a, b) => a - b).forEach(originalIndex => {
132
- const previousDeletedCell = this.deletedCellInfos.get(originalIndex - 1);
133
- if (previousDeletedCell) {
134
- const deletedCell = this.deletedCellInfos.get(originalIndex);
135
- if (deletedCell) {
136
- deletedCell.offset = previousDeletedCell.height + previousDeletedCell.offset;
137
- }
138
- }
139
- });
140
- const totalHeight = heights.reduce((prev, curr) => prev + curr, 0);
141
- this._notebookEditor.changeViewZones(accessor => {
142
- const notebookViewZone = {
143
- afterModelPosition: index,
144
- heightInPx: totalHeight + 4,
145
- domNode: rootContainer
146
- };
147
- const id = accessor.addZone(notebookViewZone);
148
- accessor.layoutZone(id);
149
- this.createdViewZones.set(index, id);
150
- const deletedCellOverviewRulereDecorationIds = this._notebookEditor.deltaCellDecorations([], [{
151
- viewZoneId: id,
152
- options: {
153
- overviewRuler: {
154
- color: overviewRulerDeletedForeground,
155
- position: NotebookOverviewRulerLane.Center
156
- }
157
- }
158
- }]);
159
- this.zoneRemover.add(toDisposable(() => {
160
- if (this.createdViewZones.get(index) === id) {
161
- this.createdViewZones.delete(index);
162
- }
163
- if (!this._notebookEditor.isDisposed) {
164
- this._notebookEditor.changeViewZones(accessor => {
165
- accessor.removeZone(id);
166
- dispose(widgets);
167
- });
168
- this._notebookEditor.deltaCellDecorations(deletedCellOverviewRulereDecorationIds, []);
169
- }
170
- }));
171
- });
172
- }
173
- };
174
- NotebookDeletedCellDecorator = ( __decorate([( __param(2, ILanguageService)), ( __param(3, IInstantiationService))], NotebookDeletedCellDecorator));
175
- let NotebookDeletedCellWidget = class NotebookDeletedCellWidget extends Disposable {
176
- constructor(
177
- _notebookEditor,
178
- _toolbarOptions,
179
- code,
180
- language,
181
- container,
182
- _originalIndex,
183
- languageService,
184
- instantiationService
185
- ) {
186
- super();
187
- this._notebookEditor = _notebookEditor;
188
- this._toolbarOptions = _toolbarOptions;
189
- this.code = code;
190
- this.language = language;
191
- this._originalIndex = _originalIndex;
192
- this.languageService = languageService;
193
- this.instantiationService = instantiationService;
194
- this.container = append(container, createElement("div"));
195
- this._register(toDisposable(() => {
196
- container.removeChild(this.container);
197
- }));
198
- }
199
- async render() {
200
- const code = this.code;
201
- const languageId = this.language;
202
- const codeHtml = await tokenizeToString(this.languageService, code, languageId);
203
- const fontInfo = this._notebookEditor.getBaseCellEditorOptions(languageId).value;
204
- const fontFamilyVar = "--notebook-editor-font-family";
205
- const fontSizeVar = "--notebook-editor-font-size";
206
- const fontWeightVar = "--notebook-editor-font-weight";
207
- const editor = ( this._notebookEditor.codeEditors.map(c => c[1])).find(c => c);
208
- const layoutInfo = editor?.getOptions().get(EditorOption.layoutInfo);
209
- const style = `` + `font-family: var(${fontFamilyVar});` + `font-weight: var(${fontWeightVar});` + `font-size: var(${fontSizeVar});` + fontInfo.lineHeight ? `line-height: ${fontInfo.lineHeight}px;` : "" + layoutInfo?.contentLeft ? `margin-left: ${layoutInfo}px;` : "" + `white-space: pre;`;
210
- const rootContainer = this.container;
211
- rootContainer.classList.add("code-cell-row");
212
- if (this._toolbarOptions) {
213
- const toolbar = createElement("div");
214
- toolbar.className = this._toolbarOptions.className;
215
- rootContainer.appendChild(toolbar);
216
- const scopedInstaService = this._register(this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, this._notebookEditor.scopedContextKeyService]))));
217
- const toolbarWidget = scopedInstaService.createInstance(MenuWorkbenchToolBar, toolbar, this._toolbarOptions.menuId, {
218
- telemetrySource: this._toolbarOptions.telemetrySource,
219
- hiddenItemStrategy: HiddenItemStrategy.NoHide,
220
- toolbarOptions: {
221
- primaryGroup: () => true
222
- },
223
- menuOptions: {
224
- renderShortTitle: true,
225
- arg: this._toolbarOptions.argFactory(this._originalIndex)
226
- },
227
- actionViewItemProvider: this._toolbarOptions.actionViewItemProvider
228
- });
229
- this._store.add(toolbarWidget);
230
- toolbar.style.position = "absolute";
231
- toolbar.style.right = "40px";
232
- toolbar.style.zIndex = "10";
233
- toolbar.classList.add("hover");
234
- }
235
- const container = append(rootContainer, $(".cell-inner-container"));
236
- container.style.position = "relative";
237
- const focusIndicatorLeft = append(container, $(
238
- ".cell-focus-indicator.cell-focus-indicator-side.cell-focus-indicator-left"
239
- ));
240
- const cellContainer = append(container, $(".cell.code"));
241
- append(focusIndicatorLeft, $("div.execution-count-label"));
242
- const editorPart = append(cellContainer, $(".cell-editor-part"));
243
- let editorContainer = append(editorPart, $(".cell-editor-container"));
244
- editorContainer = append(editorContainer, $(".code", {
245
- style
246
- }));
247
- if (fontInfo.fontFamily) {
248
- editorContainer.style.setProperty(fontFamilyVar, fontInfo.fontFamily);
249
- }
250
- if (fontInfo.fontSize) {
251
- editorContainer.style.setProperty(fontSizeVar, `${fontInfo.fontSize}px`);
252
- }
253
- if (fontInfo.fontWeight) {
254
- editorContainer.style.setProperty(fontWeightVar, fontInfo.fontWeight);
255
- }
256
- editorContainer.innerHTML = (ttPolicy?.createHTML(codeHtml) || codeHtml);
257
- const lineCount = splitLines(code).length;
258
- const height = (lineCount * (fontInfo.lineHeight || DefaultLineHeight)) + 12 + 12;
259
- const totalHeight = height + 16 + 16;
260
- return totalHeight;
261
- }
262
- };
263
- NotebookDeletedCellWidget = ( __decorate([( __param(6, ILanguageService)), ( __param(7, IInstantiationService))], NotebookDeletedCellWidget));
264
-
265
- export { NotebookDeletedCellDecorator, NotebookDeletedCellWidget };
@@ -1,24 +0,0 @@
1
- import { Disposable } from "../../../../../../base/common/lifecycle.js";
2
- import { IInstantiationService } from "../../../../../../platform/instantiation/common/instantiation.js";
3
- import { INotebookEditorWorkerService } from "../../../common/services/notebookWorkerService.service.js";
4
- import { INotebookEditorContribution, INotebookEditor } from "../../notebookBrowser.js";
5
- import { INotebookLoggingService } from "../../../common/notebookLoggingService.service.js";
6
- export declare class NotebookInlineDiffDecorationContribution extends Disposable implements INotebookEditorContribution {
7
- private readonly notebookEditor;
8
- private readonly notebookEditorWorkerService;
9
- private readonly instantiationService;
10
- private readonly logService;
11
- static ID: string;
12
- private previous?;
13
- private insertedCellDecorator;
14
- private deletedCellDecorator;
15
- private readonly cellDecorators;
16
- private cachedNotebookDiff?;
17
- private listeners;
18
- constructor(notebookEditor: INotebookEditor, notebookEditorWorkerService: INotebookEditorWorkerService, instantiationService: IInstantiationService, logService: INotebookLoggingService);
19
- private clear;
20
- dispose(): void;
21
- private initialize;
22
- private _update;
23
- private updateCells;
24
- }
@@ -1,185 +0,0 @@
1
-
2
- import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
3
- import { Event } from '../../../../../../base/common/event.js';
4
- import { Disposable } from '../../../../../../base/common/lifecycle.js';
5
- import '../../../../../../base/common/observableInternal/index.js';
6
- import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
7
- import { INotebookEditorWorkerService } from '../../../common/services/notebookWorkerService.service.js';
8
- import { registerNotebookContribution } from '../../notebookEditorExtensions.js';
9
- import { NotebookCellDiffDecorator } from './notebookCellDiffDecorator.js';
10
- import { NotebookDeletedCellDecorator } from './notebookDeletedCellDecorator.js';
11
- import { NotebookInsertedCellDecorator } from './notebookInsertedCellDecorator.js';
12
- import { INotebookLoggingService } from '../../../common/notebookLoggingService.service.js';
13
- import { computeDiff } from '../../../common/notebookDiff.js';
14
- import '../../../../../../platform/instantiation/common/extensions.js';
15
- import './notebookOriginalModelRefFactory.js';
16
- import './notebookOriginalCellModelFactory.js';
17
- import { autorun } from '../../../../../../base/common/observableInternal/reactions/autorun.js';
18
-
19
- let NotebookInlineDiffDecorationContribution = class NotebookInlineDiffDecorationContribution extends Disposable {
20
- static {
21
- this.ID = "workbench.notebook.inlineDiffDecoration";
22
- }
23
- constructor(
24
- notebookEditor,
25
- notebookEditorWorkerService,
26
- instantiationService,
27
- logService
28
- ) {
29
- super();
30
- this.notebookEditor = notebookEditor;
31
- this.notebookEditorWorkerService = notebookEditorWorkerService;
32
- this.instantiationService = instantiationService;
33
- this.logService = logService;
34
- this.cellDecorators = ( new Map());
35
- this.listeners = [];
36
- this.logService.debug("inlineDiff", "Watching for previous model");
37
- this._register(autorun(reader => {
38
- this.previous = this.notebookEditor.notebookOptions.previousModelToCompare.read(reader);
39
- if (this.previous) {
40
- this.logService.debug("inlineDiff", "Previous model set");
41
- if (this.notebookEditor.hasModel()) {
42
- this.initialize();
43
- } else {
44
- this.logService.debug("inlineDiff", "Waiting for model to attach");
45
- this.listeners.push(
46
- Event.once(this.notebookEditor.onDidAttachViewModel)(() => this.initialize())
47
- );
48
- }
49
- }
50
- }));
51
- }
52
- clear() {
53
- this.listeners.forEach(l => l.dispose());
54
- this.cellDecorators.forEach((v, cell) => {
55
- v.dispose();
56
- this.cellDecorators.delete(cell);
57
- });
58
- this.insertedCellDecorator?.dispose();
59
- this.deletedCellDecorator?.dispose();
60
- this.cachedNotebookDiff = undefined;
61
- this.listeners = [];
62
- this.logService.debug("inlineDiff", "Cleared decorations and listeners");
63
- }
64
- dispose() {
65
- this.logService.debug("inlineDiff", "Disposing");
66
- this.clear();
67
- super.dispose();
68
- }
69
- initialize() {
70
- this.clear();
71
- if (!this.previous) {
72
- return;
73
- }
74
- this.insertedCellDecorator = this.instantiationService.createInstance(NotebookInsertedCellDecorator, this.notebookEditor);
75
- this.deletedCellDecorator = this.instantiationService.createInstance(NotebookDeletedCellDecorator, this.notebookEditor, undefined);
76
- this._update();
77
- const onVisibleChange = Event.debounce(
78
- this.notebookEditor.onDidChangeVisibleRanges,
79
- e => e,
80
- 100,
81
- undefined,
82
- undefined,
83
- undefined,
84
- this._store
85
- );
86
- this.listeners.push(onVisibleChange(() => this._update()));
87
- this.listeners.push(this.notebookEditor.onDidChangeModel(() => this._update()));
88
- if (this.notebookEditor.textModel) {
89
- const onContentChange = Event.debounce(
90
- this.notebookEditor.textModel.onDidChangeContent,
91
- (_, event) => event,
92
- 100,
93
- undefined,
94
- undefined,
95
- undefined,
96
- this._store
97
- );
98
- const onOriginalContentChange = Event.debounce(
99
- this.previous.onDidChangeContent,
100
- (_, event) => event,
101
- 100,
102
- undefined,
103
- undefined,
104
- undefined,
105
- this._store
106
- );
107
- this.listeners.push(onContentChange(() => this._update()));
108
- this.listeners.push(onOriginalContentChange(() => this._update()));
109
- }
110
- this.logService.debug("inlineDiff", "Initialized");
111
- }
112
- async _update() {
113
- const current = this.notebookEditor.getViewModel()?.notebookDocument;
114
- if (!this.previous || !current) {
115
- this.logService.debug("inlineDiff", "Update skipped - no original or current document");
116
- return;
117
- }
118
- if (!this.cachedNotebookDiff || this.cachedNotebookDiff.originalVersion !== this.previous.versionId || this.cachedNotebookDiff.version !== current.versionId) {
119
- let diffInfo = {
120
- cellDiffInfo: []
121
- };
122
- try {
123
- const notebookDiff = await this.notebookEditorWorkerService.computeDiff(this.previous.uri, current.uri);
124
- diffInfo = computeDiff(this.previous, current, notebookDiff);
125
- } catch (e) {
126
- this.logService.error("inlineDiff", "Error computing diff:\n" + e);
127
- return;
128
- }
129
- this.cachedNotebookDiff = {
130
- cellDiffInfo: diffInfo.cellDiffInfo,
131
- originalVersion: this.previous.versionId,
132
- version: current.versionId
133
- };
134
- this.insertedCellDecorator?.apply(diffInfo.cellDiffInfo);
135
- this.deletedCellDecorator?.apply(diffInfo.cellDiffInfo, this.previous);
136
- }
137
- await this.updateCells(this.previous, current, this.cachedNotebookDiff.cellDiffInfo);
138
- }
139
- async updateCells(original, modified, cellDiffs) {
140
- const validDiffDecorators = ( new Set());
141
- cellDiffs.forEach(diff => {
142
- if (diff.type === "modified") {
143
- const modifiedCell = modified.cells[diff.modifiedCellIndex];
144
- const originalCell = original.cells[diff.originalCellIndex];
145
- const editor = this.notebookEditor.codeEditors.find(([vm]) => vm.handle === modifiedCell.handle)?.[1];
146
- if (editor) {
147
- const currentDecorator = this.cellDecorators.get(modifiedCell);
148
- if ((currentDecorator?.modifiedCell !== modifiedCell || currentDecorator?.originalCell !== originalCell)) {
149
- currentDecorator?.dispose();
150
- const decorator = this.instantiationService.createInstance(
151
- NotebookCellDiffDecorator,
152
- this.notebookEditor,
153
- modifiedCell,
154
- originalCell,
155
- editor
156
- );
157
- this.cellDecorators.set(modifiedCell, decorator);
158
- validDiffDecorators.add(decorator);
159
- this._register(editor.onDidDispose(() => {
160
- decorator.dispose();
161
- if (this.cellDecorators.get(modifiedCell) === decorator) {
162
- this.cellDecorators.delete(modifiedCell);
163
- }
164
- }));
165
- } else if (currentDecorator) {
166
- validDiffDecorators.add(currentDecorator);
167
- }
168
- }
169
- }
170
- });
171
- this.cellDecorators.forEach((v, cell) => {
172
- if (!( validDiffDecorators.has(v))) {
173
- v.dispose();
174
- this.cellDecorators.delete(cell);
175
- }
176
- });
177
- }
178
- };
179
- NotebookInlineDiffDecorationContribution = ( __decorate([( __param(1, INotebookEditorWorkerService)), ( __param(2, IInstantiationService)), ( __param(3, INotebookLoggingService))], NotebookInlineDiffDecorationContribution));
180
- registerNotebookContribution(
181
- NotebookInlineDiffDecorationContribution.ID,
182
- NotebookInlineDiffDecorationContribution
183
- );
184
-
185
- export { NotebookInlineDiffDecorationContribution };
@@ -1,28 +0,0 @@
1
- import * as DOM from "../../../../../../base/browser/dom.js";
2
- import { CodeWindow } from "../../../../../../base/browser/window.js";
3
- import { Disposable } from "../../../../../../base/common/lifecycle.js";
4
- import { IInstantiationService } from "../../../../../../platform/instantiation/common/instantiation.js";
5
- import { NotebookTextModel } from "@codingame/monaco-vscode-notebook-service-override/vscode/vs/workbench/contrib/notebook/common/model/notebookTextModel";
6
- import { NotebookDiffEditorInput } from "@codingame/monaco-vscode-notebook-service-override/vscode/vs/workbench/contrib/notebook/common/notebookDiffEditorInput";
7
- import { INotebookEditorOptions } from "../../notebookBrowser.js";
8
- import { NotebookEditorWidget } from "../../notebookEditorWidget.js";
9
- import { NotebookOptions } from "../../notebookOptions.js";
10
- import { INotebookEditorService } from "../../services/notebookEditorService.service.js";
11
- export declare class NotebookInlineDiffWidget extends Disposable {
12
- private readonly rootElement;
13
- private readonly groupId;
14
- private readonly window;
15
- private readonly options;
16
- private dimension;
17
- private readonly instantiationService;
18
- private readonly widgetService;
19
- private widget;
20
- private position;
21
- get editorWidget(): NotebookEditorWidget | undefined;
22
- constructor(rootElement: HTMLElement, groupId: number, window: CodeWindow, options: NotebookOptions, dimension: DOM.Dimension | undefined, instantiationService: IInstantiationService, widgetService: INotebookEditorService);
23
- show(input: NotebookDiffEditorInput, model: NotebookTextModel | undefined, previousModel: NotebookTextModel | undefined, options: INotebookEditorOptions | undefined): Promise<void>;
24
- hide(): void;
25
- setLayout(dimension: DOM.Dimension, position: DOM.IDomPosition): void;
26
- private createNotebookWidget;
27
- dispose(): void;
28
- }
@@ -1,104 +0,0 @@
1
-
2
- import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
3
- import { setParentFlowTo } from '../../../../../../base/browser/dom.js';
4
- import { Disposable } from '../../../../../../base/common/lifecycle.js';
5
- import { EditorExtensionsRegistry } from '../../../../../../editor/browser/editorExtensions.js';
6
- import { MenuId } from '../../../../../../platform/actions/common/actions.js';
7
- import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
8
- import { NotebookInlineDiffDecorationContribution } from './notebookInlineDiff.js';
9
- import { NotebookEditorExtensionsRegistry } from '../../notebookEditorExtensions.js';
10
- import { INotebookEditorService } from '../../services/notebookEditorService.service.js';
11
-
12
- let NotebookInlineDiffWidget = class NotebookInlineDiffWidget extends Disposable {
13
- get editorWidget() {
14
- return this.widget.value;
15
- }
16
- constructor(
17
- rootElement,
18
- groupId,
19
- window,
20
- options,
21
- dimension,
22
- instantiationService,
23
- widgetService
24
- ) {
25
- super();
26
- this.rootElement = rootElement;
27
- this.groupId = groupId;
28
- this.window = window;
29
- this.options = options;
30
- this.dimension = dimension;
31
- this.instantiationService = instantiationService;
32
- this.widgetService = widgetService;
33
- this.widget = {
34
- value: undefined
35
- };
36
- }
37
- async show(input, model, previousModel, options) {
38
- if (!this.widget.value) {
39
- this.createNotebookWidget(input, this.groupId, this.rootElement);
40
- }
41
- if (this.dimension) {
42
- this.widget.value?.layout(this.dimension, this.rootElement, this.position);
43
- }
44
- if (model) {
45
- await this.widget.value?.setOptions({
46
- ...options
47
- });
48
- this.widget.value?.notebookOptions.previousModelToCompare.set(previousModel, undefined);
49
- await this.widget.value.setModel(model, options?.viewState);
50
- }
51
- }
52
- hide() {
53
- if (this.widget.value) {
54
- this.widget.value.notebookOptions.previousModelToCompare.set(undefined, undefined);
55
- this.widget.value.onWillHide();
56
- }
57
- }
58
- setLayout(dimension, position) {
59
- this.dimension = dimension;
60
- this.position = position;
61
- }
62
- createNotebookWidget(input, groupId, rootElement) {
63
- const contributions = NotebookEditorExtensionsRegistry.getSomeEditorContributions([NotebookInlineDiffDecorationContribution.ID]);
64
- const menuIds = {
65
- notebookToolbar: MenuId.NotebookToolbar,
66
- cellTitleToolbar: MenuId.NotebookCellTitle,
67
- cellDeleteToolbar: MenuId.NotebookCellDelete,
68
- cellInsertToolbar: MenuId.NotebookCellBetween,
69
- cellTopInsertToolbar: MenuId.NotebookCellListTop,
70
- cellExecuteToolbar: MenuId.NotebookCellExecute,
71
- cellExecutePrimary: undefined
72
- };
73
- const skipContributions = [
74
- "editor.contrib.review",
75
- "editor.contrib.floatingClickMenu",
76
- "editor.contrib.dirtydiff",
77
- "editor.contrib.testingOutputPeek",
78
- "editor.contrib.testingDecorations",
79
- "store.contrib.stickyScrollController",
80
- "editor.contrib.findController",
81
- "editor.contrib.emptyTextEditorHint"
82
- ];
83
- const cellEditorContributions = EditorExtensionsRegistry.getEditorContributions().filter(c => skipContributions.indexOf(c.id) === -1);
84
- this.widget = this.instantiationService.invokeFunction(this.widgetService.retrieveWidget, groupId, input, {
85
- contributions,
86
- menuIds,
87
- cellEditorContributions,
88
- options: this.options
89
- }, this.dimension, this.window);
90
- if (this.rootElement && this.widget.value.getDomNode()) {
91
- this.rootElement.setAttribute("aria-flowto", this.widget.value.getDomNode().id || "");
92
- setParentFlowTo(this.widget.value.getDomNode(), this.rootElement);
93
- }
94
- }
95
- dispose() {
96
- super.dispose();
97
- if (this.widget.value) {
98
- this.widget.value.dispose();
99
- }
100
- }
101
- };
102
- NotebookInlineDiffWidget = ( __decorate([( __param(5, IInstantiationService)), ( __param(6, INotebookEditorService))], NotebookInlineDiffWidget));
103
-
104
- export { NotebookInlineDiffWidget };
@@ -1,10 +0,0 @@
1
- import { Disposable } from "../../../../../../base/common/lifecycle.js";
2
- import { CellDiffInfo } from "../notebookDiffViewModel.js";
3
- import { INotebookEditor } from "../../notebookBrowser.js";
4
- export declare class NotebookInsertedCellDecorator extends Disposable {
5
- private readonly notebookEditor;
6
- private readonly decorators;
7
- constructor(notebookEditor: INotebookEditor);
8
- apply(diffInfo: CellDiffInfo[]): void;
9
- clear(): void;
10
- }