@codingame/monaco-vscode-notebook-service-override 3.2.3 → 4.1.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 (80) hide show
  1. package/notebook.js +13 -13
  2. package/package.json +2 -2
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/override/vs/platform/dialogs/common/dialogs.js +0 -8
  6. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +0 -6
  7. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +0 -389
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +0 -608
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +0 -109
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +0 -173
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +0 -488
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +0 -106
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +0 -67
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +0 -165
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +0 -67
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +0 -320
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +0 -72
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +0 -6
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +0 -168
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +0 -209
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +0 -84
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +0 -82
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +0 -67
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +0 -91
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +0 -393
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +0 -5
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +0 -97
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +0 -118
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +0 -59
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +0 -148
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +0 -383
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +0 -77
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +0 -511
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +0 -159
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +0 -56
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +0 -94
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +0 -51
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +0 -565
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +0 -31
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController.js +0 -744
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +0 -707
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -351
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +0 -267
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -45
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1297
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -284
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -563
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -108
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -39
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +0 -6
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +0 -313
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -890
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -13
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -393
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -175
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +0 -1174
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +0 -159
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +0 -451
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +0 -192
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +0 -106
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +0 -509
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +0 -130
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +0 -341
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +0 -111
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +0 -28
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +0 -65
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +0 -641
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +0 -200
  69. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +0 -80
  70. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +0 -1003
  71. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +0 -103
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +0 -202
  73. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +0 -80
  74. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +0 -98
  75. package/vscode/src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchService.js +0 -237
  76. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +0 -89
  77. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +0 -376
  78. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +0 -408
  79. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +0 -144
  80. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +0 -129
@@ -1,509 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
- import { Disposable, combinedDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
5
- import { isEqual } from 'vscode/vscode/vs/base/common/resources';
6
- import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
7
- import { AccessibilitySignal, IAccessibilitySignalService } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
8
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
9
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
10
- import { CellUri, NotebookCellExecutionState, NotebookExecutionState } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
11
- import { INotebookExecutionService, CellExecutionUpdateType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionService';
12
- import { NotebookExecutionType, INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
13
- import { INotebookKernelService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookKernelService';
14
- import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
15
-
16
- let NotebookExecutionStateService = class NotebookExecutionStateService extends Disposable {
17
- constructor(_instantiationService, _logService, _notebookService, _accessibilitySignalService) {
18
- super();
19
- this._instantiationService = _instantiationService;
20
- this._logService = _logService;
21
- this._notebookService = _notebookService;
22
- this._accessibilitySignalService = _accessibilitySignalService;
23
- this._executions = ( new ResourceMap());
24
- this._notebookExecutions = ( new ResourceMap());
25
- this._notebookListeners = ( new ResourceMap());
26
- this._cellListeners = ( new ResourceMap());
27
- this._lastFailedCells = ( new ResourceMap());
28
- this._onDidChangeExecution = this._register(( new Emitter()));
29
- this.onDidChangeExecution = this._onDidChangeExecution.event;
30
- this._onDidChangeLastRunFailState = this._register(( new Emitter()));
31
- this.onDidChangeLastRunFailState = this._onDidChangeLastRunFailState.event;
32
- }
33
- getLastFailedCellForNotebook(notebook) {
34
- const failedCell = this._lastFailedCells.get(notebook);
35
- return failedCell?.visible ? failedCell.cellHandle : undefined;
36
- }
37
- forceCancelNotebookExecutions(notebookUri) {
38
- const notebookCellExecutions = this._executions.get(notebookUri);
39
- if (notebookCellExecutions) {
40
- for (const exe of ( notebookCellExecutions.values())) {
41
- this._onCellExecutionDidComplete(notebookUri, exe.cellHandle, exe);
42
- }
43
- }
44
- if (( this._notebookExecutions.has(notebookUri))) {
45
- this._onExecutionDidComplete(notebookUri);
46
- }
47
- }
48
- getCellExecution(cellUri) {
49
- const parsed = CellUri.parse(cellUri);
50
- if (!parsed) {
51
- throw new Error(`Not a cell URI: ${cellUri}`);
52
- }
53
- const exeMap = this._executions.get(parsed.notebook);
54
- if (exeMap) {
55
- return exeMap.get(parsed.handle);
56
- }
57
- return undefined;
58
- }
59
- getExecution(notebook) {
60
- return this._notebookExecutions.get(notebook)?.[0];
61
- }
62
- getCellExecutionsForNotebook(notebook) {
63
- const exeMap = this._executions.get(notebook);
64
- return exeMap ? Array.from(( exeMap.values())) : [];
65
- }
66
- getCellExecutionsByHandleForNotebook(notebook) {
67
- const exeMap = this._executions.get(notebook);
68
- return exeMap ? ( new Map(exeMap.entries())) : undefined;
69
- }
70
- _onCellExecutionDidChange(notebookUri, cellHandle, exe) {
71
- this._onDidChangeExecution.fire(( new NotebookCellExecutionEvent(notebookUri, cellHandle, exe)));
72
- }
73
- _onCellExecutionDidComplete(notebookUri, cellHandle, exe, lastRunSuccess) {
74
- const notebookExecutions = this._executions.get(notebookUri);
75
- if (!notebookExecutions) {
76
- this._logService.debug(`NotebookExecutionStateService#_onCellExecutionDidComplete - unknown notebook ${( notebookUri.toString())}`);
77
- return;
78
- }
79
- exe.dispose();
80
- const cellUri = CellUri.generate(notebookUri, cellHandle);
81
- this._cellListeners.get(cellUri)?.dispose();
82
- this._cellListeners.delete(cellUri);
83
- notebookExecutions.delete(cellHandle);
84
- if (notebookExecutions.size === 0) {
85
- this._executions.delete(notebookUri);
86
- this._notebookListeners.get(notebookUri)?.dispose();
87
- this._notebookListeners.delete(notebookUri);
88
- }
89
- if (lastRunSuccess !== undefined) {
90
- if (lastRunSuccess) {
91
- if (this._executions.size === 0) {
92
- this._accessibilitySignalService.playSignal(AccessibilitySignal.notebookCellCompleted);
93
- }
94
- this._clearLastFailedCell(notebookUri);
95
- }
96
- else {
97
- this._accessibilitySignalService.playSignal(AccessibilitySignal.notebookCellFailed);
98
- this._setLastFailedCell(notebookUri, cellHandle);
99
- }
100
- }
101
- this._onDidChangeExecution.fire(( new NotebookCellExecutionEvent(notebookUri, cellHandle)));
102
- }
103
- _onExecutionDidChange(notebookUri, exe) {
104
- this._onDidChangeExecution.fire(( new NotebookExecutionEvent(notebookUri, exe)));
105
- }
106
- _onExecutionDidComplete(notebookUri) {
107
- const disposables = this._notebookExecutions.get(notebookUri);
108
- if (!Array.isArray(disposables)) {
109
- this._logService.debug(`NotebookExecutionStateService#_onCellExecutionDidComplete - unknown notebook ${( notebookUri.toString())}`);
110
- return;
111
- }
112
- this._notebookExecutions.delete(notebookUri);
113
- this._onDidChangeExecution.fire(( new NotebookExecutionEvent(notebookUri)));
114
- disposables.forEach(d => d.dispose());
115
- }
116
- createCellExecution(notebookUri, cellHandle) {
117
- const notebook = this._notebookService.getNotebookTextModel(notebookUri);
118
- if (!notebook) {
119
- throw new Error(`Notebook not found: ${notebookUri.toString()}`);
120
- }
121
- let notebookExecutionMap = this._executions.get(notebookUri);
122
- if (!notebookExecutionMap) {
123
- const listeners = this._instantiationService.createInstance(NotebookExecutionListeners, notebookUri);
124
- this._notebookListeners.set(notebookUri, listeners);
125
- notebookExecutionMap = ( new Map());
126
- this._executions.set(notebookUri, notebookExecutionMap);
127
- }
128
- let exe = notebookExecutionMap.get(cellHandle);
129
- if (!exe) {
130
- exe = this._createNotebookCellExecution(notebook, cellHandle);
131
- notebookExecutionMap.set(cellHandle, exe);
132
- exe.initialize();
133
- this._onDidChangeExecution.fire(( new NotebookCellExecutionEvent(notebookUri, cellHandle, exe)));
134
- }
135
- return exe;
136
- }
137
- createExecution(notebookUri) {
138
- const notebook = this._notebookService.getNotebookTextModel(notebookUri);
139
- if (!notebook) {
140
- throw new Error(`Notebook not found: ${notebookUri.toString()}`);
141
- }
142
- if (!( this._notebookListeners.has(notebookUri))) {
143
- const listeners = this._instantiationService.createInstance(NotebookExecutionListeners, notebookUri);
144
- this._notebookListeners.set(notebookUri, listeners);
145
- }
146
- let info = this._notebookExecutions.get(notebookUri);
147
- if (!info) {
148
- info = this._createNotebookExecution(notebook);
149
- this._notebookExecutions.set(notebookUri, info);
150
- this._onDidChangeExecution.fire(( new NotebookExecutionEvent(notebookUri, info[0])));
151
- }
152
- return info[0];
153
- }
154
- _createNotebookCellExecution(notebook, cellHandle) {
155
- const notebookUri = notebook.uri;
156
- const exe = this._instantiationService.createInstance(CellExecution, cellHandle, notebook);
157
- const disposable = combinedDisposable(exe.onDidUpdate(() => this._onCellExecutionDidChange(notebookUri, cellHandle, exe)), exe.onDidComplete(lastRunSuccess => this._onCellExecutionDidComplete(notebookUri, cellHandle, exe, lastRunSuccess)));
158
- this._cellListeners.set(CellUri.generate(notebookUri, cellHandle), disposable);
159
- return exe;
160
- }
161
- _createNotebookExecution(notebook) {
162
- const notebookUri = notebook.uri;
163
- const exe = this._instantiationService.createInstance(NotebookExecution, notebook);
164
- const disposable = combinedDisposable(exe.onDidUpdate(() => this._onExecutionDidChange(notebookUri, exe)), exe.onDidComplete(() => this._onExecutionDidComplete(notebookUri)));
165
- return [exe, disposable];
166
- }
167
- _setLastFailedCell(notebookURI, cellHandle) {
168
- const prevLastFailedCellInfo = this._lastFailedCells.get(notebookURI);
169
- const notebook = this._notebookService.getNotebookTextModel(notebookURI);
170
- if (!notebook) {
171
- return;
172
- }
173
- const newLastFailedCellInfo = {
174
- cellHandle: cellHandle,
175
- disposable: prevLastFailedCellInfo ? prevLastFailedCellInfo.disposable : this._getFailedCellListener(notebook),
176
- visible: true
177
- };
178
- this._lastFailedCells.set(notebookURI, newLastFailedCellInfo);
179
- this._onDidChangeLastRunFailState.fire({ visible: true, notebook: notebookURI });
180
- }
181
- _setLastFailedCellVisibility(notebookURI, visible) {
182
- const lastFailedCellInfo = this._lastFailedCells.get(notebookURI);
183
- if (lastFailedCellInfo) {
184
- this._lastFailedCells.set(notebookURI, {
185
- cellHandle: lastFailedCellInfo.cellHandle,
186
- disposable: lastFailedCellInfo.disposable,
187
- visible: visible,
188
- });
189
- }
190
- this._onDidChangeLastRunFailState.fire({ visible: visible, notebook: notebookURI });
191
- }
192
- _clearLastFailedCell(notebookURI) {
193
- const lastFailedCellInfo = this._lastFailedCells.get(notebookURI);
194
- if (lastFailedCellInfo) {
195
- lastFailedCellInfo.disposable?.dispose();
196
- this._lastFailedCells.delete(notebookURI);
197
- }
198
- this._onDidChangeLastRunFailState.fire({ visible: false, notebook: notebookURI });
199
- }
200
- _getFailedCellListener(notebook) {
201
- return notebook.onWillAddRemoveCells((e) => {
202
- const lastFailedCell = this._lastFailedCells.get(notebook.uri)?.cellHandle;
203
- if (lastFailedCell !== undefined) {
204
- const lastFailedCellPos = notebook.cells.findIndex(c => c.handle === lastFailedCell);
205
- e.rawEvent.changes.forEach(([start, deleteCount, addedCells]) => {
206
- if (deleteCount) {
207
- if (lastFailedCellPos >= start && lastFailedCellPos < start + deleteCount) {
208
- this._setLastFailedCellVisibility(notebook.uri, false);
209
- }
210
- }
211
- if (( addedCells.some(cell => cell.handle === lastFailedCell))) {
212
- this._setLastFailedCellVisibility(notebook.uri, true);
213
- }
214
- });
215
- }
216
- });
217
- }
218
- dispose() {
219
- super.dispose();
220
- this._executions.forEach(executionMap => {
221
- executionMap.forEach(execution => execution.dispose());
222
- executionMap.clear();
223
- });
224
- this._executions.clear();
225
- this._notebookExecutions.forEach(disposables => {
226
- disposables.forEach(d => d.dispose());
227
- });
228
- this._notebookExecutions.clear();
229
- this._cellListeners.forEach(disposable => disposable.dispose());
230
- this._notebookListeners.forEach(disposable => disposable.dispose());
231
- this._lastFailedCells.forEach(elem => elem.disposable.dispose());
232
- }
233
- };
234
- NotebookExecutionStateService = ( __decorate([
235
- ( __param(0, IInstantiationService)),
236
- ( __param(1, ILogService)),
237
- ( __param(2, INotebookService)),
238
- ( __param(3, IAccessibilitySignalService))
239
- ], NotebookExecutionStateService));
240
- class NotebookCellExecutionEvent {
241
- constructor(notebook, cellHandle, changed) {
242
- this.notebook = notebook;
243
- this.cellHandle = cellHandle;
244
- this.changed = changed;
245
- this.type = NotebookExecutionType.cell;
246
- }
247
- affectsCell(cell) {
248
- const parsedUri = CellUri.parse(cell);
249
- return !!parsedUri && isEqual(this.notebook, parsedUri.notebook) && this.cellHandle === parsedUri.handle;
250
- }
251
- affectsNotebook(notebook) {
252
- return isEqual(this.notebook, notebook);
253
- }
254
- }
255
- class NotebookExecutionEvent {
256
- constructor(notebook, changed) {
257
- this.notebook = notebook;
258
- this.changed = changed;
259
- this.type = NotebookExecutionType.notebook;
260
- }
261
- affectsNotebook(notebook) {
262
- return isEqual(this.notebook, notebook);
263
- }
264
- }
265
- let NotebookExecutionListeners = class NotebookExecutionListeners extends Disposable {
266
- constructor(notebook, _notebookService, _notebookKernelService, _notebookExecutionService, _notebookExecutionStateService, _logService) {
267
- super();
268
- this._notebookService = _notebookService;
269
- this._notebookKernelService = _notebookKernelService;
270
- this._notebookExecutionService = _notebookExecutionService;
271
- this._notebookExecutionStateService = _notebookExecutionStateService;
272
- this._logService = _logService;
273
- this._logService.debug(`NotebookExecution#ctor ${( notebook.toString())}`);
274
- const notebookModel = this._notebookService.getNotebookTextModel(notebook);
275
- if (!notebookModel) {
276
- throw new Error('Notebook not found: ' + notebook);
277
- }
278
- this._notebookModel = notebookModel;
279
- this._register(this._notebookModel.onWillAddRemoveCells(e => this.onWillAddRemoveCells(e)));
280
- this._register(this._notebookModel.onWillDispose(() => this.onWillDisposeDocument()));
281
- }
282
- cancelAll() {
283
- this._logService.debug(`NotebookExecutionListeners#cancelAll`);
284
- const exes = this._notebookExecutionStateService.getCellExecutionsForNotebook(this._notebookModel.uri);
285
- this._notebookExecutionService.cancelNotebookCellHandles(this._notebookModel, ( exes.map(exe => exe.cellHandle)));
286
- }
287
- onWillDisposeDocument() {
288
- this._logService.debug(`NotebookExecution#onWillDisposeDocument`);
289
- this.cancelAll();
290
- }
291
- onWillAddRemoveCells(e) {
292
- const notebookExes = this._notebookExecutionStateService.getCellExecutionsByHandleForNotebook(this._notebookModel.uri);
293
- const executingDeletedHandles = ( new Set());
294
- const pendingDeletedHandles = ( new Set());
295
- if (notebookExes) {
296
- e.rawEvent.changes.forEach(([start, deleteCount]) => {
297
- if (deleteCount) {
298
- const deletedHandles = ( this._notebookModel.cells.slice(start, start + deleteCount).map(c => c.handle));
299
- deletedHandles.forEach(h => {
300
- const exe = notebookExes.get(h);
301
- if (exe?.state === NotebookCellExecutionState.Executing) {
302
- executingDeletedHandles.add(h);
303
- }
304
- else if (exe) {
305
- pendingDeletedHandles.add(h);
306
- }
307
- });
308
- }
309
- });
310
- }
311
- if (executingDeletedHandles.size || pendingDeletedHandles.size) {
312
- const kernel = this._notebookKernelService.getSelectedOrSuggestedKernel(this._notebookModel);
313
- if (kernel) {
314
- const implementsInterrupt = kernel.implementsInterrupt;
315
- const handlesToCancel = implementsInterrupt ? [...executingDeletedHandles] : [...executingDeletedHandles, ...pendingDeletedHandles];
316
- this._logService.debug(`NotebookExecution#onWillAddRemoveCells, ${JSON.stringify([...handlesToCancel])}`);
317
- if (handlesToCancel.length) {
318
- kernel.cancelNotebookCellExecution(this._notebookModel.uri, handlesToCancel);
319
- }
320
- }
321
- }
322
- }
323
- };
324
- NotebookExecutionListeners = ( __decorate([
325
- ( __param(1, INotebookService)),
326
- ( __param(2, INotebookKernelService)),
327
- ( __param(3, INotebookExecutionService)),
328
- ( __param(4, INotebookExecutionStateService)),
329
- ( __param(5, ILogService))
330
- ], NotebookExecutionListeners));
331
- function updateToEdit(update, cellHandle) {
332
- if (update.editType === CellExecutionUpdateType.Output) {
333
- return {
334
- editType: 2 ,
335
- handle: update.cellHandle,
336
- append: update.append,
337
- outputs: update.outputs,
338
- };
339
- }
340
- else if (update.editType === CellExecutionUpdateType.OutputItems) {
341
- return {
342
- editType: 7 ,
343
- items: update.items,
344
- append: update.append,
345
- outputId: update.outputId
346
- };
347
- }
348
- else if (update.editType === CellExecutionUpdateType.ExecutionState) {
349
- const newInternalMetadata = {};
350
- if (typeof update.executionOrder !== 'undefined') {
351
- newInternalMetadata.executionOrder = update.executionOrder;
352
- }
353
- if (typeof update.runStartTime !== 'undefined') {
354
- newInternalMetadata.runStartTime = update.runStartTime;
355
- }
356
- return {
357
- editType: 9 ,
358
- handle: cellHandle,
359
- internalMetadata: newInternalMetadata
360
- };
361
- }
362
- throw new Error('Unknown cell update type');
363
- }
364
- let CellExecution = class CellExecution extends Disposable {
365
- get state() {
366
- return this._state;
367
- }
368
- get notebook() {
369
- return this._notebookModel.uri;
370
- }
371
- get didPause() {
372
- return this._didPause;
373
- }
374
- get isPaused() {
375
- return this._isPaused;
376
- }
377
- constructor(cellHandle, _notebookModel, _logService) {
378
- super();
379
- this.cellHandle = cellHandle;
380
- this._notebookModel = _notebookModel;
381
- this._logService = _logService;
382
- this._onDidUpdate = this._register(( new Emitter()));
383
- this.onDidUpdate = this._onDidUpdate.event;
384
- this._onDidComplete = this._register(( new Emitter()));
385
- this.onDidComplete = this._onDidComplete.event;
386
- this._state = NotebookCellExecutionState.Unconfirmed;
387
- this._didPause = false;
388
- this._isPaused = false;
389
- this._logService.debug(`CellExecution#ctor ${this.getCellLog()}`);
390
- }
391
- initialize() {
392
- const startExecuteEdit = {
393
- editType: 9 ,
394
- handle: this.cellHandle,
395
- internalMetadata: {
396
- executionId: generateUuid(),
397
- runStartTime: null,
398
- runEndTime: null,
399
- lastRunSuccess: null,
400
- executionOrder: null,
401
- renderDuration: null,
402
- }
403
- };
404
- this._applyExecutionEdits([startExecuteEdit]);
405
- }
406
- getCellLog() {
407
- return `${( this._notebookModel.uri.toString())}, ${this.cellHandle}`;
408
- }
409
- logUpdates(updates) {
410
- const updateTypes = ( updates.map(u => CellExecutionUpdateType[u.editType])).join(', ');
411
- this._logService.debug(`CellExecution#updateExecution ${this.getCellLog()}, [${updateTypes}]`);
412
- }
413
- confirm() {
414
- this._logService.debug(`CellExecution#confirm ${this.getCellLog()}`);
415
- this._state = NotebookCellExecutionState.Pending;
416
- this._onDidUpdate.fire();
417
- }
418
- update(updates) {
419
- this.logUpdates(updates);
420
- if (( updates.some(u => u.editType === CellExecutionUpdateType.ExecutionState))) {
421
- this._state = NotebookCellExecutionState.Executing;
422
- }
423
- if (!this._didPause && ( updates.some(u => u.editType === CellExecutionUpdateType.ExecutionState && u.didPause))) {
424
- this._didPause = true;
425
- }
426
- const lastIsPausedUpdate = [...updates].reverse().find(u => u.editType === CellExecutionUpdateType.ExecutionState && typeof u.isPaused === 'boolean');
427
- if (lastIsPausedUpdate) {
428
- this._isPaused = lastIsPausedUpdate.isPaused;
429
- }
430
- const cellModel = this._notebookModel.cells.find(c => c.handle === this.cellHandle);
431
- if (!cellModel) {
432
- this._logService.debug(`CellExecution#update, updating cell not in notebook: ${( this._notebookModel.uri.toString())}, ${this.cellHandle}`);
433
- }
434
- else {
435
- const edits = ( updates.map(update => updateToEdit(update, this.cellHandle)));
436
- this._applyExecutionEdits(edits);
437
- }
438
- if (( updates.some(u => u.editType === CellExecutionUpdateType.ExecutionState))) {
439
- this._onDidUpdate.fire();
440
- }
441
- }
442
- complete(completionData) {
443
- const cellModel = this._notebookModel.cells.find(c => c.handle === this.cellHandle);
444
- if (!cellModel) {
445
- this._logService.debug(`CellExecution#complete, completing cell not in notebook: ${( this._notebookModel.uri.toString())}, ${this.cellHandle}`);
446
- }
447
- else {
448
- const edit = {
449
- editType: 9 ,
450
- handle: this.cellHandle,
451
- internalMetadata: {
452
- lastRunSuccess: completionData.lastRunSuccess,
453
- runStartTime: this._didPause ? null : cellModel.internalMetadata.runStartTime,
454
- runEndTime: this._didPause ? null : completionData.runEndTime,
455
- }
456
- };
457
- this._applyExecutionEdits([edit]);
458
- }
459
- this._onDidComplete.fire(completionData.lastRunSuccess);
460
- }
461
- _applyExecutionEdits(edits) {
462
- this._notebookModel.applyEdits(edits, true, undefined, () => undefined, undefined, false);
463
- }
464
- };
465
- CellExecution = ( __decorate([
466
- ( __param(2, ILogService))
467
- ], CellExecution));
468
- let NotebookExecution = class NotebookExecution extends Disposable {
469
- get state() {
470
- return this._state;
471
- }
472
- get notebook() {
473
- return this._notebookModel.uri;
474
- }
475
- constructor(_notebookModel, _logService) {
476
- super();
477
- this._notebookModel = _notebookModel;
478
- this._logService = _logService;
479
- this._onDidUpdate = this._register(( new Emitter()));
480
- this.onDidUpdate = this._onDidUpdate.event;
481
- this._onDidComplete = this._register(( new Emitter()));
482
- this.onDidComplete = this._onDidComplete.event;
483
- this._state = NotebookExecutionState.Unconfirmed;
484
- this._logService.debug(`NotebookExecution#ctor`);
485
- }
486
- debug(message) {
487
- this._logService.debug(`${message} ${( this._notebookModel.uri.toString())}`);
488
- }
489
- confirm() {
490
- this.debug(`Execution#confirm`);
491
- this._state = NotebookExecutionState.Pending;
492
- this._onDidUpdate.fire();
493
- }
494
- begin() {
495
- this.debug(`Execution#begin`);
496
- this._state = NotebookExecutionState.Executing;
497
- this._onDidUpdate.fire();
498
- }
499
- complete() {
500
- this.debug(`Execution#begin`);
501
- this._state = NotebookExecutionState.Unconfirmed;
502
- this._onDidComplete.fire();
503
- }
504
- };
505
- NotebookExecution = ( __decorate([
506
- ( __param(1, ILogService))
507
- ], NotebookExecution));
508
-
509
- export { NotebookExecutionStateService };
@@ -1,130 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
- import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
3
- import { LinkedMap } from 'vscode/vscode/vs/base/common/map';
4
- import { localize2WithPath } from 'vscode/vscode/vs/nls';
5
- import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
6
- import { registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
7
- import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
8
- import { INotebookKernelHistoryService, INotebookKernelService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookKernelService';
9
- import { INotebookLoggingService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookLoggingService';
10
-
11
- var NotebookKernelHistoryService_1;
12
- const MAX_KERNELS_IN_HISTORY = 5;
13
- let NotebookKernelHistoryService = class NotebookKernelHistoryService extends Disposable {
14
- static { NotebookKernelHistoryService_1 = this; }
15
- static { this.STORAGE_KEY = 'notebook.kernelHistory'; }
16
- constructor(_storageService, _notebookKernelService, _notebookLoggingService) {
17
- super();
18
- this._storageService = _storageService;
19
- this._notebookKernelService = _notebookKernelService;
20
- this._notebookLoggingService = _notebookLoggingService;
21
- this._mostRecentKernelsMap = {};
22
- this._loadState();
23
- this._register(this._storageService.onWillSaveState(() => this._saveState()));
24
- this._register(this._storageService.onDidChangeValue(1 , NotebookKernelHistoryService_1.STORAGE_KEY, this._register(( new DisposableStore())))(() => {
25
- this._loadState();
26
- }));
27
- }
28
- getKernels(notebook) {
29
- const allAvailableKernels = this._notebookKernelService.getMatchingKernel(notebook);
30
- const allKernels = allAvailableKernels.all;
31
- const selectedKernel = allAvailableKernels.selected;
32
- const suggested = allAvailableKernels.all.length === 1 ? allAvailableKernels.all[0] : undefined;
33
- this._notebookLoggingService.debug('History', `getMatchingKernels: ${allAvailableKernels.all.length} kernels available for ${notebook.uri.path}. Selected: ${allAvailableKernels.selected?.label}. Suggested: ${suggested?.label}`);
34
- const mostRecentKernelIds = this._mostRecentKernelsMap[notebook.viewType] ? [...( this._mostRecentKernelsMap[notebook.viewType].values())] : [];
35
- const all = ( mostRecentKernelIds.map(kernelId => allKernels.find(kernel => kernel.id === kernelId))).filter(kernel => !!kernel);
36
- this._notebookLoggingService.debug('History', `mru: ${mostRecentKernelIds.length} kernels in history, ${all.length} registered already.`);
37
- return {
38
- selected: selectedKernel ?? suggested,
39
- all
40
- };
41
- }
42
- addMostRecentKernel(kernel) {
43
- const key = kernel.id;
44
- const viewType = kernel.viewType;
45
- const recentKeynels = this._mostRecentKernelsMap[viewType] ?? ( new LinkedMap());
46
- recentKeynels.set(key, key, 1 );
47
- if (recentKeynels.size > MAX_KERNELS_IN_HISTORY) {
48
- const reserved = [...recentKeynels.entries()].slice(0, MAX_KERNELS_IN_HISTORY);
49
- recentKeynels.fromJSON(reserved);
50
- }
51
- this._mostRecentKernelsMap[viewType] = recentKeynels;
52
- }
53
- _saveState() {
54
- let notEmpty = false;
55
- for (const [_, kernels] of Object.entries(this._mostRecentKernelsMap)) {
56
- notEmpty = notEmpty || kernels.size > 0;
57
- }
58
- if (notEmpty) {
59
- const serialized = this._serialize();
60
- this._storageService.store(NotebookKernelHistoryService_1.STORAGE_KEY, JSON.stringify(serialized), 1 , 0 );
61
- }
62
- else {
63
- this._storageService.remove(NotebookKernelHistoryService_1.STORAGE_KEY, 1 );
64
- }
65
- }
66
- _loadState() {
67
- const serialized = this._storageService.get(NotebookKernelHistoryService_1.STORAGE_KEY, 1 );
68
- if (serialized) {
69
- try {
70
- this._deserialize(JSON.parse(serialized));
71
- }
72
- catch (e) {
73
- this._mostRecentKernelsMap = {};
74
- }
75
- }
76
- else {
77
- this._mostRecentKernelsMap = {};
78
- }
79
- }
80
- _serialize() {
81
- const result = Object.create(null);
82
- for (const [viewType, kernels] of Object.entries(this._mostRecentKernelsMap)) {
83
- result[viewType] = {
84
- entries: [...( kernels.values())]
85
- };
86
- }
87
- return result;
88
- }
89
- _deserialize(serialized) {
90
- this._mostRecentKernelsMap = {};
91
- for (const [viewType, kernels] of Object.entries(serialized)) {
92
- const linkedMap = ( new LinkedMap());
93
- const mapValues = [];
94
- for (const entry of kernels.entries) {
95
- mapValues.push([entry, entry]);
96
- }
97
- linkedMap.fromJSON(mapValues);
98
- this._mostRecentKernelsMap[viewType] = linkedMap;
99
- }
100
- }
101
- _clear() {
102
- this._mostRecentKernelsMap = {};
103
- this._saveState();
104
- }
105
- };
106
- NotebookKernelHistoryService = NotebookKernelHistoryService_1 = ( __decorate([
107
- ( __param(0, IStorageService)),
108
- ( __param(1, INotebookKernelService)),
109
- ( __param(2, INotebookLoggingService))
110
- ], NotebookKernelHistoryService));
111
- registerAction2(class extends Action2 {
112
- constructor() {
113
- super({
114
- id: 'notebook.clearNotebookKernelsMRUCache',
115
- title: ( localize2WithPath(
116
- 'vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl',
117
- 'workbench.notebook.clearNotebookKernelsMRUCache',
118
- "Clear Notebook Kernels MRU Cache"
119
- )),
120
- category: Categories.Developer,
121
- f1: true
122
- });
123
- }
124
- async run(accessor) {
125
- const historyService = accessor.get(INotebookKernelHistoryService);
126
- historyService._clear();
127
- }
128
- });
129
-
130
- export { NotebookKernelHistoryService };