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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  2. package/external/tslib/tslib.es6.js +11 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +1 -0
  5. package/notebook.d.ts +5 -0
  6. package/notebook.js +44 -0
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +32 -0
  9. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +6 -0
  10. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +387 -0
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +668 -0
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +109 -0
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +319 -0
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +58 -0
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +173 -0
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +485 -0
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +106 -0
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +67 -0
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +165 -0
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +67 -0
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +238 -0
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +72 -0
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +6 -0
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +168 -0
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +317 -0
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +209 -0
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +87 -0
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +82 -0
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +67 -0
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +93 -0
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +383 -0
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +51 -0
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +46 -0
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +135 -0
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +383 -0
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +117 -0
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +511 -0
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +168 -0
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +57 -0
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +94 -0
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +51 -0
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +702 -0
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +268 -0
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +45 -0
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +1297 -0
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +284 -0
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +563 -0
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +108 -0
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +39 -0
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +6 -0
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +313 -0
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +872 -0
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +13 -0
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +393 -0
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +175 -0
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +1121 -0
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +159 -0
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +339 -0
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl.js +41 -0
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +182 -0
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +106 -0
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +509 -0
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +133 -0
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +342 -0
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +111 -0
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +28 -0
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +65 -0
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +666 -0
  69. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +200 -0
  70. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +80 -0
  71. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +1001 -0
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +103 -0
  73. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +202 -0
  74. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +80 -0
  75. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +98 -0
  76. package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +217 -0
  77. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +89 -0
  78. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +372 -0
  79. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopy.js +706 -0
  80. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +407 -0
  81. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +144 -0
  82. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +129 -0
  83. package/worker.js +1 -0
  84. package/workers/notebook.worker.js +9 -0
@@ -0,0 +1,702 @@
1
+ import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
2
+ import { isEqual } from 'monaco-editor/esm/vs/base/common/resources.js';
3
+ import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
4
+ import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
5
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
6
+ import { registerAction2, MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
7
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
8
+ import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
9
+ import { IDebugService } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
10
+ import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
11
+ import { CTX_INLINE_CHAT_FOCUSED } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
12
+ import { insertCell } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/cellOperations';
13
+ import { NotebookAction, executeNotebookCondition, getContextFromUri, getContextFromActiveEditor, NotebookMultiCellAction, NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT, cellExecutionArgs, parseMultiCellExecutionArgs, CELL_TITLE_CELL_GROUP_ID, NotebookCellAction } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
14
+ import { EXECUTE_CELL_COMMAND_ID, ScrollToRevealBehavior, CellEditState, CellFocusMode } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
15
+ import { executeAllIcon, executeIcon, executeAboveIcon, executeBelowIcon, stopIcon, executingStateIcon, errorStateIcon } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
16
+ import { NotebookSetting, CellKind, CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
17
+ import { NOTEBOOK_CELL_TYPE, NOTEBOOK_KERNEL_COUNT, NOTEBOOK_KERNEL_SOURCE_COUNT, NOTEBOOK_MISSING_KERNEL_EXTENSION, NOTEBOOK_CELL_EXECUTING, NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_INTERRUPTIBLE_KERNEL, NOTEBOOK_HAS_SOMETHING_RUNNING, NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_EXECUTION_STATE, NOTEBOOK_HAS_RUNNING_CELL, NOTEBOOK_LAST_CELL_FAILED } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
18
+ import { NotebookEditorInput } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput';
19
+ import { INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
20
+ import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
21
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
22
+
23
+ const EXECUTE_NOTEBOOK_COMMAND_ID = 'notebook.execute';
24
+ const CANCEL_NOTEBOOK_COMMAND_ID = 'notebook.cancelExecution';
25
+ const INTERRUPT_NOTEBOOK_COMMAND_ID = 'notebook.interruptExecution';
26
+ const CANCEL_CELL_COMMAND_ID = 'notebook.cell.cancelExecution';
27
+ const EXECUTE_CELL_FOCUS_CONTAINER_COMMAND_ID = 'notebook.cell.executeAndFocusContainer';
28
+ const EXECUTE_CELL_SELECT_BELOW = 'notebook.cell.executeAndSelectBelow';
29
+ const EXECUTE_CELL_INSERT_BELOW = 'notebook.cell.executeAndInsertBelow';
30
+ const EXECUTE_CELL_AND_BELOW = 'notebook.cell.executeCellAndBelow';
31
+ const EXECUTE_CELLS_ABOVE = 'notebook.cell.executeCellsAbove';
32
+ const RENDER_ALL_MARKDOWN_CELLS = 'notebook.renderAllMarkdownCells';
33
+ const REVEAL_RUNNING_CELL = 'notebook.revealRunningCell';
34
+ const REVEAL_LAST_FAILED_CELL = 'notebook.revealLastFailedCell';
35
+ const executeCondition = ( ContextKeyExpr.and(( NOTEBOOK_CELL_TYPE.isEqualTo('code')), ( ContextKeyExpr.or(
36
+ ContextKeyExpr.greater(NOTEBOOK_KERNEL_COUNT.key, 0),
37
+ ContextKeyExpr.greater(NOTEBOOK_KERNEL_SOURCE_COUNT.key, 0),
38
+ NOTEBOOK_MISSING_KERNEL_EXTENSION
39
+ ))));
40
+ const executeThisCellCondition = ( ContextKeyExpr.and(executeCondition, ( NOTEBOOK_CELL_EXECUTING.toNegated())));
41
+ function renderAllMarkdownCells(context) {
42
+ for (let i = 0; i < context.notebookEditor.getLength(); i++) {
43
+ const cell = context.notebookEditor.cellAt(i);
44
+ if (cell.cellKind === CellKind.Markup) {
45
+ cell.updateEditState(CellEditState.Preview, 'renderAllMarkdownCells');
46
+ }
47
+ }
48
+ }
49
+ async function runCell(editorGroupsService, context) {
50
+ const group = editorGroupsService.activeGroup;
51
+ if (group) {
52
+ if (group.activeEditor) {
53
+ group.pinEditor(group.activeEditor);
54
+ }
55
+ }
56
+ if (context.ui && context.cell) {
57
+ await context.notebookEditor.executeNotebookCells(Iterable.single(context.cell));
58
+ if (context.autoReveal) {
59
+ const cellIndex = context.notebookEditor.getCellIndex(context.cell);
60
+ context.notebookEditor.revealCellRangeInView({ start: cellIndex, end: cellIndex + 1 });
61
+ }
62
+ }
63
+ else if (context.selectedCells?.length || context.cell) {
64
+ const selectedCells = context.selectedCells?.length ? context.selectedCells : [context.cell];
65
+ await context.notebookEditor.executeNotebookCells(selectedCells);
66
+ const firstCell = selectedCells[0];
67
+ if (firstCell && context.autoReveal) {
68
+ const cellIndex = context.notebookEditor.getCellIndex(firstCell);
69
+ context.notebookEditor.revealCellRangeInView({ start: cellIndex, end: cellIndex + 1 });
70
+ }
71
+ }
72
+ let foundEditor = undefined;
73
+ for (const [, codeEditor] of context.notebookEditor.codeEditors) {
74
+ if (isEqual(codeEditor.getModel()?.uri, (context.cell ?? context.selectedCells?.[0])?.uri)) {
75
+ foundEditor = codeEditor;
76
+ break;
77
+ }
78
+ }
79
+ if (!foundEditor) {
80
+ return;
81
+ }
82
+ const controller = InlineChatController.get(foundEditor);
83
+ if (!controller) {
84
+ return;
85
+ }
86
+ controller.createSnapshot();
87
+ }
88
+ registerAction2(class RenderAllMarkdownCellsAction extends NotebookAction {
89
+ constructor() {
90
+ super({
91
+ id: RENDER_ALL_MARKDOWN_CELLS,
92
+ title: ( localizeWithPath(
93
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
94
+ 'notebookActions.renderMarkdown',
95
+ "Render All Markdown Cells"
96
+ )),
97
+ });
98
+ }
99
+ async runWithContext(accessor, context) {
100
+ renderAllMarkdownCells(context);
101
+ }
102
+ });
103
+ registerAction2(class ExecuteNotebookAction extends NotebookAction {
104
+ constructor() {
105
+ super({
106
+ id: EXECUTE_NOTEBOOK_COMMAND_ID,
107
+ title: ( localizeWithPath(
108
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
109
+ 'notebookActions.executeNotebook',
110
+ "Run All"
111
+ )),
112
+ icon: executeAllIcon,
113
+ metadata: {
114
+ description: ( localizeWithPath(
115
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
116
+ 'notebookActions.executeNotebook',
117
+ "Run All"
118
+ )),
119
+ args: [
120
+ {
121
+ name: 'uri',
122
+ description: 'The document uri'
123
+ }
124
+ ]
125
+ },
126
+ menu: [
127
+ {
128
+ id: MenuId.EditorTitle,
129
+ order: -1,
130
+ group: 'navigation',
131
+ when: ( ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, executeNotebookCondition, ( ContextKeyExpr.or(( NOTEBOOK_INTERRUPTIBLE_KERNEL.toNegated()), ( NOTEBOOK_HAS_SOMETHING_RUNNING.toNegated()))), ( ContextKeyExpr.notEquals('config.notebook.globalToolbar', true))))
132
+ },
133
+ {
134
+ id: MenuId.NotebookToolbar,
135
+ order: -1,
136
+ group: 'navigation/execute',
137
+ when: ( ContextKeyExpr.and(executeNotebookCondition, ( ContextKeyExpr.or(( NOTEBOOK_INTERRUPTIBLE_KERNEL.toNegated()), ( NOTEBOOK_HAS_SOMETHING_RUNNING.toNegated()))), ( ContextKeyExpr.and(NOTEBOOK_HAS_SOMETHING_RUNNING, ( NOTEBOOK_INTERRUPTIBLE_KERNEL.toNegated())))?.negate(), ( ContextKeyExpr.equals('config.notebook.globalToolbar', true))))
138
+ }
139
+ ]
140
+ });
141
+ }
142
+ getEditorContextFromArgsOrActive(accessor, context) {
143
+ return getContextFromUri(accessor, context) ?? getContextFromActiveEditor(accessor.get(IEditorService));
144
+ }
145
+ async runWithContext(accessor, context) {
146
+ renderAllMarkdownCells(context);
147
+ const editorService = accessor.get(IEditorService);
148
+ const editor = editorService.getEditors(0 ).find(editor => editor.editor instanceof NotebookEditorInput && editor.editor.viewType === context.notebookEditor.textModel.viewType && ( editor.editor.resource.toString()) === ( context.notebookEditor.textModel.uri.toString()));
149
+ const editorGroupService = accessor.get(IEditorGroupsService);
150
+ if (editor) {
151
+ const group = editorGroupService.getGroup(editor.groupId);
152
+ group?.pinEditor(editor.editor);
153
+ }
154
+ return context.notebookEditor.executeNotebookCells();
155
+ }
156
+ });
157
+ registerAction2(class ExecuteCell extends NotebookMultiCellAction {
158
+ constructor() {
159
+ super({
160
+ id: EXECUTE_CELL_COMMAND_ID,
161
+ precondition: executeThisCellCondition,
162
+ title: ( localizeWithPath(
163
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
164
+ 'notebookActions.execute',
165
+ "Execute Cell"
166
+ )),
167
+ keybinding: {
168
+ when: NOTEBOOK_CELL_LIST_FOCUSED,
169
+ primary: 256 | 3 ,
170
+ win: {
171
+ primary: 2048 | 512 | 3
172
+ },
173
+ weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
174
+ },
175
+ menu: {
176
+ id: MenuId.NotebookCellExecutePrimary,
177
+ when: executeThisCellCondition,
178
+ group: 'inline'
179
+ },
180
+ metadata: {
181
+ description: ( localizeWithPath(
182
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
183
+ 'notebookActions.execute',
184
+ "Execute Cell"
185
+ )),
186
+ args: cellExecutionArgs
187
+ },
188
+ icon: executeIcon
189
+ });
190
+ }
191
+ parseArgs(accessor, ...args) {
192
+ return parseMultiCellExecutionArgs(accessor, ...args);
193
+ }
194
+ async runWithContext(accessor, context) {
195
+ const editorGroupsService = accessor.get(IEditorGroupsService);
196
+ if (context.ui) {
197
+ await context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
198
+ }
199
+ await runCell(editorGroupsService, context);
200
+ }
201
+ });
202
+ registerAction2(class ExecuteAboveCells extends NotebookMultiCellAction {
203
+ constructor() {
204
+ super({
205
+ id: EXECUTE_CELLS_ABOVE,
206
+ precondition: executeCondition,
207
+ title: ( localizeWithPath(
208
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
209
+ 'notebookActions.executeAbove',
210
+ "Execute Above Cells"
211
+ )),
212
+ menu: [
213
+ {
214
+ id: MenuId.NotebookCellExecute,
215
+ when: ( ContextKeyExpr.and(executeCondition, ( ContextKeyExpr.equals(`config.${NotebookSetting.consolidatedRunButton}`, true))))
216
+ },
217
+ {
218
+ id: MenuId.NotebookCellTitle,
219
+ order: 1 ,
220
+ group: CELL_TITLE_CELL_GROUP_ID,
221
+ when: ( ContextKeyExpr.and(executeCondition, ( ContextKeyExpr.equals(`config.${NotebookSetting.consolidatedRunButton}`, false))))
222
+ }
223
+ ],
224
+ icon: executeAboveIcon
225
+ });
226
+ }
227
+ parseArgs(accessor, ...args) {
228
+ return parseMultiCellExecutionArgs(accessor, ...args);
229
+ }
230
+ async runWithContext(accessor, context) {
231
+ let endCellIdx = undefined;
232
+ if (context.ui) {
233
+ endCellIdx = context.notebookEditor.getCellIndex(context.cell);
234
+ await context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
235
+ }
236
+ else {
237
+ endCellIdx = Math.min(...( context.selectedCells.map(cell => context.notebookEditor.getCellIndex(cell))));
238
+ }
239
+ if (typeof endCellIdx === 'number') {
240
+ const range = { start: 0, end: endCellIdx };
241
+ const cells = context.notebookEditor.getCellsInRange(range);
242
+ context.notebookEditor.executeNotebookCells(cells);
243
+ }
244
+ }
245
+ });
246
+ registerAction2(class ExecuteCellAndBelow extends NotebookMultiCellAction {
247
+ constructor() {
248
+ super({
249
+ id: EXECUTE_CELL_AND_BELOW,
250
+ precondition: executeCondition,
251
+ title: ( localizeWithPath(
252
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
253
+ 'notebookActions.executeBelow',
254
+ "Execute Cell and Below"
255
+ )),
256
+ menu: [
257
+ {
258
+ id: MenuId.NotebookCellExecute,
259
+ when: ( ContextKeyExpr.and(executeCondition, ( ContextKeyExpr.equals(`config.${NotebookSetting.consolidatedRunButton}`, true))))
260
+ },
261
+ {
262
+ id: MenuId.NotebookCellTitle,
263
+ order: 2 ,
264
+ group: CELL_TITLE_CELL_GROUP_ID,
265
+ when: ( ContextKeyExpr.and(executeCondition, ( ContextKeyExpr.equals(`config.${NotebookSetting.consolidatedRunButton}`, false))))
266
+ }
267
+ ],
268
+ icon: executeBelowIcon
269
+ });
270
+ }
271
+ parseArgs(accessor, ...args) {
272
+ return parseMultiCellExecutionArgs(accessor, ...args);
273
+ }
274
+ async runWithContext(accessor, context) {
275
+ let startCellIdx = undefined;
276
+ if (context.ui) {
277
+ startCellIdx = context.notebookEditor.getCellIndex(context.cell);
278
+ await context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
279
+ }
280
+ else {
281
+ startCellIdx = Math.min(...( context.selectedCells.map(cell => context.notebookEditor.getCellIndex(cell))));
282
+ }
283
+ if (typeof startCellIdx === 'number') {
284
+ const range = { start: startCellIdx, end: context.notebookEditor.getLength() };
285
+ const cells = context.notebookEditor.getCellsInRange(range);
286
+ context.notebookEditor.executeNotebookCells(cells);
287
+ }
288
+ }
289
+ });
290
+ registerAction2(class ExecuteCellFocusContainer extends NotebookMultiCellAction {
291
+ constructor() {
292
+ super({
293
+ id: EXECUTE_CELL_FOCUS_CONTAINER_COMMAND_ID,
294
+ precondition: executeThisCellCondition,
295
+ title: ( localizeWithPath(
296
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
297
+ 'notebookActions.executeAndFocusContainer',
298
+ "Execute Cell and Focus Container"
299
+ )),
300
+ metadata: {
301
+ description: ( localizeWithPath(
302
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
303
+ 'notebookActions.executeAndFocusContainer',
304
+ "Execute Cell and Focus Container"
305
+ )),
306
+ args: cellExecutionArgs
307
+ },
308
+ icon: executeIcon
309
+ });
310
+ }
311
+ parseArgs(accessor, ...args) {
312
+ return parseMultiCellExecutionArgs(accessor, ...args);
313
+ }
314
+ async runWithContext(accessor, context) {
315
+ const editorGroupsService = accessor.get(IEditorGroupsService);
316
+ if (context.ui) {
317
+ await context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
318
+ }
319
+ else {
320
+ const firstCell = context.selectedCells[0];
321
+ if (firstCell) {
322
+ await context.notebookEditor.focusNotebookCell(firstCell, 'container', { skipReveal: true });
323
+ }
324
+ }
325
+ await runCell(editorGroupsService, context);
326
+ }
327
+ });
328
+ const cellCancelCondition = ( ContextKeyExpr.or(( ContextKeyExpr.equals(NOTEBOOK_CELL_EXECUTION_STATE.key, 'executing')), ( ContextKeyExpr.equals(NOTEBOOK_CELL_EXECUTION_STATE.key, 'pending'))));
329
+ registerAction2(class CancelExecuteCell extends NotebookMultiCellAction {
330
+ constructor() {
331
+ super({
332
+ id: CANCEL_CELL_COMMAND_ID,
333
+ precondition: cellCancelCondition,
334
+ title: ( localizeWithPath(
335
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
336
+ 'notebookActions.cancel',
337
+ "Stop Cell Execution"
338
+ )),
339
+ icon: stopIcon,
340
+ menu: {
341
+ id: MenuId.NotebookCellExecutePrimary,
342
+ when: cellCancelCondition,
343
+ group: 'inline'
344
+ },
345
+ metadata: {
346
+ description: ( localizeWithPath(
347
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
348
+ 'notebookActions.cancel',
349
+ "Stop Cell Execution"
350
+ )),
351
+ args: [
352
+ {
353
+ name: 'options',
354
+ description: 'The cell range options',
355
+ schema: {
356
+ 'type': 'object',
357
+ 'required': ['ranges'],
358
+ 'properties': {
359
+ 'ranges': {
360
+ 'type': 'array',
361
+ items: [
362
+ {
363
+ 'type': 'object',
364
+ 'required': ['start', 'end'],
365
+ 'properties': {
366
+ 'start': {
367
+ 'type': 'number'
368
+ },
369
+ 'end': {
370
+ 'type': 'number'
371
+ }
372
+ }
373
+ }
374
+ ]
375
+ },
376
+ 'document': {
377
+ 'type': 'object',
378
+ 'description': 'The document uri',
379
+ }
380
+ }
381
+ }
382
+ }
383
+ ]
384
+ },
385
+ });
386
+ }
387
+ parseArgs(accessor, ...args) {
388
+ return parseMultiCellExecutionArgs(accessor, ...args);
389
+ }
390
+ async runWithContext(accessor, context) {
391
+ if (context.ui) {
392
+ await context.notebookEditor.focusNotebookCell(context.cell, 'container', { skipReveal: true });
393
+ return context.notebookEditor.cancelNotebookCells(Iterable.single(context.cell));
394
+ }
395
+ else {
396
+ return context.notebookEditor.cancelNotebookCells(context.selectedCells);
397
+ }
398
+ }
399
+ });
400
+ registerAction2(class ExecuteCellSelectBelow extends NotebookCellAction {
401
+ constructor() {
402
+ super({
403
+ id: EXECUTE_CELL_SELECT_BELOW,
404
+ precondition: ( ContextKeyExpr.or(executeThisCellCondition, ( NOTEBOOK_CELL_TYPE.isEqualTo('markup')))),
405
+ title: ( localizeWithPath(
406
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
407
+ 'notebookActions.executeAndSelectBelow',
408
+ "Execute Notebook Cell and Select Below"
409
+ )),
410
+ keybinding: {
411
+ when: ( ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, ( CTX_INLINE_CHAT_FOCUSED.negate()))),
412
+ primary: 1024 | 3 ,
413
+ weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
414
+ },
415
+ });
416
+ }
417
+ async runWithContext(accessor, context) {
418
+ const editorGroupsService = accessor.get(IEditorGroupsService);
419
+ const idx = context.notebookEditor.getCellIndex(context.cell);
420
+ if (typeof idx !== 'number') {
421
+ return;
422
+ }
423
+ const languageService = accessor.get(ILanguageService);
424
+ const config = accessor.get(IConfigurationService);
425
+ const scrollBehavior = config.getValue(NotebookSetting.scrollToRevealCell);
426
+ let focusOptions;
427
+ if (scrollBehavior === 'none') {
428
+ focusOptions = { skipReveal: true };
429
+ }
430
+ else {
431
+ focusOptions = {
432
+ revealBehavior: scrollBehavior === 'fullCell' ? ScrollToRevealBehavior.fullCell : ScrollToRevealBehavior.firstLine
433
+ };
434
+ }
435
+ if (context.cell.cellKind === CellKind.Markup) {
436
+ const nextCell = context.notebookEditor.cellAt(idx + 1);
437
+ context.cell.updateEditState(CellEditState.Preview, EXECUTE_CELL_SELECT_BELOW);
438
+ if (nextCell) {
439
+ await context.notebookEditor.focusNotebookCell(nextCell, 'container', focusOptions);
440
+ }
441
+ else {
442
+ const newCell = insertCell(languageService, context.notebookEditor, idx, CellKind.Markup, 'below');
443
+ if (newCell) {
444
+ await context.notebookEditor.focusNotebookCell(newCell, 'editor', focusOptions);
445
+ }
446
+ }
447
+ return;
448
+ }
449
+ else {
450
+ const nextCell = context.notebookEditor.cellAt(idx + 1);
451
+ if (nextCell) {
452
+ await context.notebookEditor.focusNotebookCell(nextCell, 'container', focusOptions);
453
+ }
454
+ else {
455
+ const newCell = insertCell(languageService, context.notebookEditor, idx, CellKind.Code, 'below');
456
+ if (newCell) {
457
+ await context.notebookEditor.focusNotebookCell(newCell, 'editor', focusOptions);
458
+ }
459
+ }
460
+ return runCell(editorGroupsService, context);
461
+ }
462
+ }
463
+ });
464
+ registerAction2(class ExecuteCellInsertBelow extends NotebookCellAction {
465
+ constructor() {
466
+ super({
467
+ id: EXECUTE_CELL_INSERT_BELOW,
468
+ precondition: ( ContextKeyExpr.or(executeThisCellCondition, ( NOTEBOOK_CELL_TYPE.isEqualTo('markup')))),
469
+ title: ( localizeWithPath(
470
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
471
+ 'notebookActions.executeAndInsertBelow',
472
+ "Execute Notebook Cell and Insert Below"
473
+ )),
474
+ keybinding: {
475
+ when: NOTEBOOK_CELL_LIST_FOCUSED,
476
+ primary: 512 | 3 ,
477
+ weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
478
+ },
479
+ });
480
+ }
481
+ async runWithContext(accessor, context) {
482
+ const editorGroupsService = accessor.get(IEditorGroupsService);
483
+ const idx = context.notebookEditor.getCellIndex(context.cell);
484
+ const languageService = accessor.get(ILanguageService);
485
+ const newFocusMode = context.cell.focusMode === CellFocusMode.Editor ? 'editor' : 'container';
486
+ const newCell = insertCell(languageService, context.notebookEditor, idx, context.cell.cellKind, 'below');
487
+ if (newCell) {
488
+ await context.notebookEditor.focusNotebookCell(newCell, newFocusMode);
489
+ }
490
+ if (context.cell.cellKind === CellKind.Markup) {
491
+ context.cell.updateEditState(CellEditState.Preview, EXECUTE_CELL_INSERT_BELOW);
492
+ }
493
+ else {
494
+ runCell(editorGroupsService, context);
495
+ }
496
+ }
497
+ });
498
+ class CancelNotebook extends NotebookAction {
499
+ getEditorContextFromArgsOrActive(accessor, context) {
500
+ return getContextFromUri(accessor, context) ?? getContextFromActiveEditor(accessor.get(IEditorService));
501
+ }
502
+ async runWithContext(accessor, context) {
503
+ return context.notebookEditor.cancelNotebookCells();
504
+ }
505
+ }
506
+ registerAction2(class CancelAllNotebook extends CancelNotebook {
507
+ constructor() {
508
+ super({
509
+ id: CANCEL_NOTEBOOK_COMMAND_ID,
510
+ title: {
511
+ value: ( localizeWithPath(
512
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
513
+ 'notebookActions.cancelNotebook',
514
+ "Stop Execution"
515
+ )),
516
+ original: 'Stop Execution'
517
+ },
518
+ icon: stopIcon,
519
+ menu: [
520
+ {
521
+ id: MenuId.EditorTitle,
522
+ order: -1,
523
+ group: 'navigation',
524
+ when: ( ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_HAS_SOMETHING_RUNNING, ( NOTEBOOK_INTERRUPTIBLE_KERNEL.toNegated()), ( ContextKeyExpr.notEquals('config.notebook.globalToolbar', true))))
525
+ },
526
+ {
527
+ id: MenuId.NotebookToolbar,
528
+ order: -1,
529
+ group: 'navigation/execute',
530
+ when: ( ContextKeyExpr.and(NOTEBOOK_HAS_SOMETHING_RUNNING, ( NOTEBOOK_INTERRUPTIBLE_KERNEL.toNegated()), ( ContextKeyExpr.equals('config.notebook.globalToolbar', true))))
531
+ }
532
+ ]
533
+ });
534
+ }
535
+ });
536
+ registerAction2(class InterruptNotebook extends CancelNotebook {
537
+ constructor() {
538
+ super({
539
+ id: INTERRUPT_NOTEBOOK_COMMAND_ID,
540
+ title: {
541
+ value: ( localizeWithPath(
542
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
543
+ 'notebookActions.interruptNotebook',
544
+ "Interrupt"
545
+ )),
546
+ original: 'Interrupt'
547
+ },
548
+ precondition: ( ContextKeyExpr.and(NOTEBOOK_HAS_SOMETHING_RUNNING, NOTEBOOK_INTERRUPTIBLE_KERNEL)),
549
+ icon: stopIcon,
550
+ menu: [
551
+ {
552
+ id: MenuId.EditorTitle,
553
+ order: -1,
554
+ group: 'navigation',
555
+ when: ( ContextKeyExpr.and(
556
+ NOTEBOOK_IS_ACTIVE_EDITOR,
557
+ NOTEBOOK_HAS_SOMETHING_RUNNING,
558
+ NOTEBOOK_INTERRUPTIBLE_KERNEL,
559
+ ( ContextKeyExpr.notEquals('config.notebook.globalToolbar', true))
560
+ ))
561
+ },
562
+ {
563
+ id: MenuId.NotebookToolbar,
564
+ order: -1,
565
+ group: 'navigation/execute',
566
+ when: ( ContextKeyExpr.and(
567
+ NOTEBOOK_HAS_SOMETHING_RUNNING,
568
+ NOTEBOOK_INTERRUPTIBLE_KERNEL,
569
+ ( ContextKeyExpr.equals('config.notebook.globalToolbar', true))
570
+ ))
571
+ },
572
+ {
573
+ id: MenuId.InteractiveToolbar,
574
+ group: 'navigation/execute'
575
+ }
576
+ ]
577
+ });
578
+ }
579
+ });
580
+ registerAction2(class RevealRunningCellAction extends NotebookAction {
581
+ constructor() {
582
+ super({
583
+ id: REVEAL_RUNNING_CELL,
584
+ title: ( localizeWithPath(
585
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
586
+ 'revealRunningCell',
587
+ "Go to Running Cell"
588
+ )),
589
+ tooltip: ( localizeWithPath(
590
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
591
+ 'revealRunningCell',
592
+ "Go to Running Cell"
593
+ )),
594
+ shortTitle: ( localizeWithPath(
595
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
596
+ 'revealRunningCellShort',
597
+ "Go To"
598
+ )),
599
+ precondition: NOTEBOOK_HAS_RUNNING_CELL,
600
+ menu: [
601
+ {
602
+ id: MenuId.EditorTitle,
603
+ when: ( ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_HAS_RUNNING_CELL, ( ContextKeyExpr.notEquals('config.notebook.globalToolbar', true)))),
604
+ group: 'navigation',
605
+ order: 0
606
+ },
607
+ {
608
+ id: MenuId.NotebookToolbar,
609
+ when: ( ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_HAS_RUNNING_CELL, ( ContextKeyExpr.equals('config.notebook.globalToolbar', true)))),
610
+ group: 'navigation/execute',
611
+ order: 20
612
+ },
613
+ {
614
+ id: MenuId.InteractiveToolbar,
615
+ when: ( ContextKeyExpr.and(NOTEBOOK_HAS_RUNNING_CELL, ( ContextKeyExpr.equals('activeEditor', 'workbench.editor.interactive')))),
616
+ group: 'navigation',
617
+ order: 10
618
+ }
619
+ ],
620
+ icon: ThemeIcon.modify(executingStateIcon, 'spin')
621
+ });
622
+ }
623
+ async runWithContext(accessor, context) {
624
+ const notebookExecutionStateService = accessor.get(INotebookExecutionStateService);
625
+ const notebook = context.notebookEditor.textModel.uri;
626
+ const executingCells = notebookExecutionStateService.getCellExecutionsForNotebook(notebook);
627
+ if (executingCells[0]) {
628
+ const topStackFrameCell = this.findCellAtTopFrame(accessor, notebook);
629
+ const focusHandle = topStackFrameCell ?? executingCells[0].cellHandle;
630
+ const cell = context.notebookEditor.getCellByHandle(focusHandle);
631
+ if (cell) {
632
+ context.notebookEditor.focusNotebookCell(cell, 'container');
633
+ }
634
+ }
635
+ }
636
+ findCellAtTopFrame(accessor, notebook) {
637
+ const debugService = accessor.get(IDebugService);
638
+ for (const session of debugService.getModel().getSessions()) {
639
+ for (const thread of session.getAllThreads()) {
640
+ const sf = thread.getTopStackFrame();
641
+ if (sf) {
642
+ const parsed = CellUri.parse(sf.source.uri);
643
+ if (parsed && ( parsed.notebook.toString()) === ( notebook.toString())) {
644
+ return parsed.handle;
645
+ }
646
+ }
647
+ }
648
+ }
649
+ return undefined;
650
+ }
651
+ });
652
+ registerAction2(class RevealLastFailedCellAction extends NotebookAction {
653
+ constructor() {
654
+ super({
655
+ id: REVEAL_LAST_FAILED_CELL,
656
+ title: ( localizeWithPath(
657
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
658
+ 'revealLastFailedCell',
659
+ "Go to Most Recently Failed Cell"
660
+ )),
661
+ tooltip: ( localizeWithPath(
662
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
663
+ 'revealLastFailedCell',
664
+ "Go to Most Recently Failed Cell"
665
+ )),
666
+ shortTitle: ( localizeWithPath(
667
+ 'vs/workbench/contrib/notebook/browser/controller/executeActions',
668
+ 'revealLastFailedCellShort',
669
+ "Go To"
670
+ )),
671
+ precondition: NOTEBOOK_LAST_CELL_FAILED,
672
+ menu: [
673
+ {
674
+ id: MenuId.EditorTitle,
675
+ when: ( ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_LAST_CELL_FAILED, ( NOTEBOOK_HAS_RUNNING_CELL.toNegated()), ( ContextKeyExpr.notEquals('config.notebook.globalToolbar', true)))),
676
+ group: 'navigation',
677
+ order: 0
678
+ },
679
+ {
680
+ id: MenuId.NotebookToolbar,
681
+ when: ( ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_LAST_CELL_FAILED, ( NOTEBOOK_HAS_RUNNING_CELL.toNegated()), ( ContextKeyExpr.equals('config.notebook.globalToolbar', true)))),
682
+ group: 'navigation/execute',
683
+ order: 20
684
+ },
685
+ ],
686
+ icon: errorStateIcon,
687
+ });
688
+ }
689
+ async runWithContext(accessor, context) {
690
+ const notebookExecutionStateService = accessor.get(INotebookExecutionStateService);
691
+ const notebook = context.notebookEditor.textModel.uri;
692
+ const lastFailedCellHandle = notebookExecutionStateService.getLastFailedCellForNotebook(notebook);
693
+ if (lastFailedCellHandle !== undefined) {
694
+ const lastFailedCell = context.notebookEditor.getCellByHandle(lastFailedCellHandle);
695
+ if (lastFailedCell) {
696
+ context.notebookEditor.focusNotebookCell(lastFailedCell, 'container');
697
+ }
698
+ }
699
+ }
700
+ });
701
+
702
+ export { executeCondition, executeThisCellCondition };