@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,488 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
- import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
3
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
5
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
6
- import { NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
7
- import { getNotebookEditorFromEditorPane, expandCellRangesWithHiddenCells, cellRangeToViewCells } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
8
- import { CopyAction, PasteAction, CutAction } from 'vscode/vscode/vs/editor/contrib/clipboard/browser/clipboard';
9
- import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService';
10
- import { cloneNotebookCellTextModel } from 'vscode/vscode/vs/workbench/contrib/notebook/common/model/notebookCellTextModel';
11
- import { SelectionStateType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
12
- import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
13
- import { isNative } from 'vscode/vscode/vs/base/common/platform';
14
- import { registerAction2, MenuId, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
15
- import { NotebookCellAction, NotebookAction, NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
16
- import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
17
- import { InputFocusedContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkeys';
18
- import { UndoCommand, RedoCommand } from 'vscode/vscode/vs/editor/browser/editorExtensions';
19
- import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
20
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
21
- import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
22
- import { showWindowLogActionId } from 'vscode/vscode/vs/workbench/services/log/common/logConstants';
23
- import { getWindow, getActiveElement, isAncestor } from 'vscode/vscode/vs/base/browser/dom';
24
-
25
- let _logging = false;
26
- function toggleLogging() {
27
- _logging = !_logging;
28
- }
29
- function _log(loggerService, str) {
30
- if (_logging) {
31
- loggerService.info(`[NotebookClipboard]: ${str}`);
32
- }
33
- }
34
- function getFocusedWebviewDelegate(accessor) {
35
- const loggerService = accessor.get(ILogService);
36
- const editorService = accessor.get(IEditorService);
37
- const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
38
- if (!editor) {
39
- _log(loggerService, '[Revive Webview] No notebook editor found for active editor pane, bypass');
40
- return;
41
- }
42
- if (!editor.hasEditorFocus()) {
43
- _log(loggerService, '[Revive Webview] Notebook editor is not focused, bypass');
44
- return;
45
- }
46
- if (!editor.hasWebviewFocus()) {
47
- _log(loggerService, '[Revive Webview] Notebook editor backlayer webview is not focused, bypass');
48
- return;
49
- }
50
- const webview = editor.getInnerWebview();
51
- _log(loggerService, '[Revive Webview] Notebook editor backlayer webview is focused');
52
- return webview;
53
- }
54
- function withWebview(accessor, f) {
55
- const webview = getFocusedWebviewDelegate(accessor);
56
- if (webview) {
57
- f(webview);
58
- return true;
59
- }
60
- return false;
61
- }
62
- const PRIORITY = 105;
63
- UndoCommand.addImplementation(PRIORITY, 'notebook-webview', accessor => {
64
- return withWebview(accessor, webview => webview.undo());
65
- });
66
- RedoCommand.addImplementation(PRIORITY, 'notebook-webview', accessor => {
67
- return withWebview(accessor, webview => webview.redo());
68
- });
69
- CopyAction?.addImplementation(PRIORITY, 'notebook-webview', accessor => {
70
- return withWebview(accessor, webview => webview.copy());
71
- });
72
- PasteAction?.addImplementation(PRIORITY, 'notebook-webview', accessor => {
73
- return withWebview(accessor, webview => webview.paste());
74
- });
75
- CutAction?.addImplementation(PRIORITY, 'notebook-webview', accessor => {
76
- return withWebview(accessor, webview => webview.cut());
77
- });
78
- function runPasteCells(editor, activeCell, pasteCells) {
79
- if (!editor.hasModel()) {
80
- return false;
81
- }
82
- const textModel = editor.textModel;
83
- if (editor.isReadOnly) {
84
- return false;
85
- }
86
- const originalState = {
87
- kind: SelectionStateType.Index,
88
- focus: editor.getFocus(),
89
- selections: editor.getSelections()
90
- };
91
- if (activeCell) {
92
- const currCellIndex = editor.getCellIndex(activeCell);
93
- const newFocusIndex = typeof currCellIndex === 'number' ? currCellIndex + 1 : 0;
94
- textModel.applyEdits([
95
- {
96
- editType: 1 ,
97
- index: newFocusIndex,
98
- count: 0,
99
- cells: ( pasteCells.items.map(cell => cloneNotebookCellTextModel(cell)))
100
- }
101
- ], true, originalState, () => ({
102
- kind: SelectionStateType.Index,
103
- focus: { start: newFocusIndex, end: newFocusIndex + 1 },
104
- selections: [{ start: newFocusIndex, end: newFocusIndex + pasteCells.items.length }]
105
- }), undefined, true);
106
- }
107
- else {
108
- if (editor.getLength() !== 0) {
109
- return false;
110
- }
111
- textModel.applyEdits([
112
- {
113
- editType: 1 ,
114
- index: 0,
115
- count: 0,
116
- cells: ( pasteCells.items.map(cell => cloneNotebookCellTextModel(cell)))
117
- }
118
- ], true, originalState, () => ({
119
- kind: SelectionStateType.Index,
120
- focus: { start: 0, end: 1 },
121
- selections: [{ start: 1, end: pasteCells.items.length + 1 }]
122
- }), undefined, true);
123
- }
124
- return true;
125
- }
126
- function runCopyCells(accessor, editor, targetCell) {
127
- if (!editor.hasModel()) {
128
- return false;
129
- }
130
- if (editor.hasOutputTextSelection()) {
131
- getWindow(editor.getDomNode()).document.execCommand('copy');
132
- return true;
133
- }
134
- const clipboardService = accessor.get(IClipboardService);
135
- const notebookService = accessor.get(INotebookService);
136
- const selections = editor.getSelections();
137
- if (targetCell) {
138
- const targetCellIndex = editor.getCellIndex(targetCell);
139
- const containingSelection = selections.find(selection => selection.start <= targetCellIndex && targetCellIndex < selection.end);
140
- if (!containingSelection) {
141
- clipboardService.writeText(targetCell.getText());
142
- notebookService.setToCopy([targetCell.model], true);
143
- return true;
144
- }
145
- }
146
- const selectionRanges = expandCellRangesWithHiddenCells(editor, editor.getSelections());
147
- const selectedCells = cellRangeToViewCells(editor, selectionRanges);
148
- if (!selectedCells.length) {
149
- return false;
150
- }
151
- clipboardService.writeText(( selectedCells.map(cell => cell.getText())).join('\n'));
152
- notebookService.setToCopy(( selectedCells.map(cell => cell.model)), true);
153
- return true;
154
- }
155
- function runCutCells(accessor, editor, targetCell) {
156
- if (!editor.hasModel() || editor.isReadOnly) {
157
- return false;
158
- }
159
- const textModel = editor.textModel;
160
- const clipboardService = accessor.get(IClipboardService);
161
- const notebookService = accessor.get(INotebookService);
162
- const selections = editor.getSelections();
163
- if (targetCell) {
164
- const targetCellIndex = editor.getCellIndex(targetCell);
165
- const containingSelection = selections.find(selection => selection.start <= targetCellIndex && targetCellIndex < selection.end);
166
- if (!containingSelection) {
167
- clipboardService.writeText(targetCell.getText());
168
- const focus = editor.getFocus();
169
- const newFocus = focus.end <= targetCellIndex ? focus : { start: focus.start - 1, end: focus.end - 1 };
170
- const newSelections = ( selections.map(
171
- selection => (selection.end <= targetCellIndex ? selection : { start: selection.start - 1, end: selection.end - 1 })
172
- ));
173
- textModel.applyEdits([
174
- { editType: 1 , index: targetCellIndex, count: 1, cells: [] }
175
- ], true, { kind: SelectionStateType.Index, focus: editor.getFocus(), selections: selections }, () => ({ kind: SelectionStateType.Index, focus: newFocus, selections: newSelections }), undefined, true);
176
- notebookService.setToCopy([targetCell.model], false);
177
- return true;
178
- }
179
- }
180
- const focus = editor.getFocus();
181
- const containingSelection = selections.find(selection => selection.start <= focus.start && focus.end <= selection.end);
182
- if (!containingSelection) {
183
- const targetCell = editor.cellAt(focus.start);
184
- clipboardService.writeText(targetCell.getText());
185
- const newFocus = focus.end === editor.getLength() ? { start: focus.start - 1, end: focus.end - 1 } : focus;
186
- const newSelections = ( selections.map(
187
- selection => (selection.end <= focus.start ? selection : { start: selection.start - 1, end: selection.end - 1 })
188
- ));
189
- textModel.applyEdits([
190
- { editType: 1 , index: focus.start, count: 1, cells: [] }
191
- ], true, { kind: SelectionStateType.Index, focus: editor.getFocus(), selections: selections }, () => ({ kind: SelectionStateType.Index, focus: newFocus, selections: newSelections }), undefined, true);
192
- notebookService.setToCopy([targetCell.model], false);
193
- return true;
194
- }
195
- const selectionRanges = expandCellRangesWithHiddenCells(editor, editor.getSelections());
196
- const selectedCells = cellRangeToViewCells(editor, selectionRanges);
197
- if (!selectedCells.length) {
198
- return false;
199
- }
200
- clipboardService.writeText(( selectedCells.map(cell => cell.getText())).join('\n'));
201
- const edits = ( selectionRanges.map(
202
- range => ({ editType: 1 , index: range.start, count: range.end - range.start, cells: [] })
203
- ));
204
- const firstSelectIndex = selectionRanges[0].start;
205
- const newFocusedCellIndex = firstSelectIndex < textModel.cells.length - 1
206
- ? firstSelectIndex
207
- : Math.max(textModel.cells.length - 2, 0);
208
- textModel.applyEdits(edits, true, { kind: SelectionStateType.Index, focus: editor.getFocus(), selections: selectionRanges }, () => {
209
- return {
210
- kind: SelectionStateType.Index,
211
- focus: { start: newFocusedCellIndex, end: newFocusedCellIndex + 1 },
212
- selections: [{ start: newFocusedCellIndex, end: newFocusedCellIndex + 1 }]
213
- };
214
- }, undefined, true);
215
- notebookService.setToCopy(( selectedCells.map(cell => cell.model)), false);
216
- return true;
217
- }
218
- let NotebookClipboardContribution = class NotebookClipboardContribution extends Disposable {
219
- static { this.ID = 'workbench.contrib.notebookClipboard'; }
220
- constructor(_editorService) {
221
- super();
222
- this._editorService = _editorService;
223
- const PRIORITY = 105;
224
- if (CopyAction) {
225
- this._register(CopyAction.addImplementation(PRIORITY, 'notebook-clipboard', accessor => {
226
- return this.runCopyAction(accessor);
227
- }));
228
- }
229
- if (PasteAction) {
230
- this._register(PasteAction.addImplementation(PRIORITY, 'notebook-clipboard', accessor => {
231
- return this.runPasteAction(accessor);
232
- }));
233
- }
234
- if (CutAction) {
235
- this._register(CutAction.addImplementation(PRIORITY, 'notebook-clipboard', accessor => {
236
- return this.runCutAction(accessor);
237
- }));
238
- }
239
- }
240
- _getContext() {
241
- const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
242
- const activeCell = editor?.getActiveCell();
243
- return {
244
- editor,
245
- activeCell
246
- };
247
- }
248
- _focusInsideEmebedMonaco(editor) {
249
- const windowSelection = getWindow(editor.getDomNode()).getSelection();
250
- if (windowSelection?.rangeCount !== 1) {
251
- return false;
252
- }
253
- const activeSelection = windowSelection.getRangeAt(0);
254
- if (activeSelection.startContainer === activeSelection.endContainer && activeSelection.endOffset - activeSelection.startOffset === 0) {
255
- return false;
256
- }
257
- let container = activeSelection.commonAncestorContainer;
258
- const body = editor.getDomNode();
259
- if (!body.contains(container)) {
260
- return false;
261
- }
262
- while (container
263
- &&
264
- container !== body) {
265
- if (container.classList && container.classList.contains('monaco-editor')) {
266
- return true;
267
- }
268
- container = container.parentNode;
269
- }
270
- return false;
271
- }
272
- runCopyAction(accessor) {
273
- const loggerService = accessor.get(ILogService);
274
- const activeElement = getActiveElement();
275
- if (activeElement instanceof HTMLElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) {
276
- _log(loggerService, '[NotebookEditor] focus is on input or textarea element, bypass');
277
- return false;
278
- }
279
- const { editor } = this._getContext();
280
- if (!editor) {
281
- _log(loggerService, '[NotebookEditor] no active notebook editor, bypass');
282
- return false;
283
- }
284
- if (!isAncestor(activeElement, editor.getDomNode())) {
285
- _log(loggerService, '[NotebookEditor] focus is outside of the notebook editor, bypass');
286
- return false;
287
- }
288
- if (this._focusInsideEmebedMonaco(editor)) {
289
- _log(loggerService, '[NotebookEditor] focus is on embed monaco editor, bypass');
290
- return false;
291
- }
292
- _log(loggerService, '[NotebookEditor] run copy actions on notebook model');
293
- return runCopyCells(accessor, editor, undefined);
294
- }
295
- runPasteAction(accessor) {
296
- const activeElement = getActiveElement();
297
- if (activeElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) {
298
- return false;
299
- }
300
- const notebookService = accessor.get(INotebookService);
301
- const pasteCells = notebookService.getToCopy();
302
- if (!pasteCells) {
303
- return false;
304
- }
305
- const { editor, activeCell } = this._getContext();
306
- if (!editor) {
307
- return false;
308
- }
309
- return runPasteCells(editor, activeCell, pasteCells);
310
- }
311
- runCutAction(accessor) {
312
- const activeElement = getActiveElement();
313
- if (activeElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) {
314
- return false;
315
- }
316
- const { editor } = this._getContext();
317
- if (!editor) {
318
- return false;
319
- }
320
- return runCutCells(accessor, editor, undefined);
321
- }
322
- };
323
- NotebookClipboardContribution = ( __decorate([
324
- ( __param(0, IEditorService))
325
- ], NotebookClipboardContribution));
326
- registerWorkbenchContribution2(NotebookClipboardContribution.ID, NotebookClipboardContribution, 2 );
327
- const COPY_CELL_COMMAND_ID = 'notebook.cell.copy';
328
- const CUT_CELL_COMMAND_ID = 'notebook.cell.cut';
329
- const PASTE_CELL_COMMAND_ID = 'notebook.cell.paste';
330
- const PASTE_CELL_ABOVE_COMMAND_ID = 'notebook.cell.pasteAbove';
331
- registerAction2(class extends NotebookCellAction {
332
- constructor() {
333
- super({
334
- id: COPY_CELL_COMMAND_ID,
335
- title: ( localizeWithPath(
336
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
337
- 'notebookActions.copy',
338
- "Copy Cell"
339
- )),
340
- menu: {
341
- id: MenuId.NotebookCellTitle,
342
- when: NOTEBOOK_EDITOR_FOCUSED,
343
- group: "1_copy" ,
344
- },
345
- keybinding: isNative ? undefined : {
346
- primary: 2048 | 33 ,
347
- win: { primary: 2048 | 33 , secondary: [2048 | 19 ] },
348
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
349
- weight: 200
350
- }
351
- });
352
- }
353
- async runWithContext(accessor, context) {
354
- runCopyCells(accessor, context.notebookEditor, context.cell);
355
- }
356
- });
357
- registerAction2(class extends NotebookCellAction {
358
- constructor() {
359
- super({
360
- id: CUT_CELL_COMMAND_ID,
361
- title: ( localizeWithPath(
362
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
363
- 'notebookActions.cut',
364
- "Cut Cell"
365
- )),
366
- menu: {
367
- id: MenuId.NotebookCellTitle,
368
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE)),
369
- group: "1_copy" ,
370
- },
371
- keybinding: isNative ? undefined : {
372
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
373
- primary: 2048 | 54 ,
374
- win: { primary: 2048 | 54 , secondary: [1024 | 20 ] },
375
- weight: 200
376
- }
377
- });
378
- }
379
- async runWithContext(accessor, context) {
380
- runCutCells(accessor, context.notebookEditor, context.cell);
381
- }
382
- });
383
- registerAction2(class extends NotebookAction {
384
- constructor() {
385
- super({
386
- id: PASTE_CELL_COMMAND_ID,
387
- title: ( localizeWithPath(
388
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
389
- 'notebookActions.paste',
390
- "Paste Cell"
391
- )),
392
- menu: {
393
- id: MenuId.NotebookCellTitle,
394
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE)),
395
- group: "1_copy" ,
396
- },
397
- keybinding: isNative ? undefined : {
398
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
399
- primary: 2048 | 52 ,
400
- win: { primary: 2048 | 52 , secondary: [1024 | 19 ] },
401
- linux: { primary: 2048 | 52 , secondary: [1024 | 19 ] },
402
- weight: 100
403
- }
404
- });
405
- }
406
- async runWithContext(accessor, context) {
407
- const notebookService = accessor.get(INotebookService);
408
- const pasteCells = notebookService.getToCopy();
409
- if (!context.notebookEditor.hasModel() || context.notebookEditor.isReadOnly) {
410
- return;
411
- }
412
- if (!pasteCells) {
413
- return;
414
- }
415
- runPasteCells(context.notebookEditor, context.cell, pasteCells);
416
- }
417
- });
418
- registerAction2(class extends NotebookCellAction {
419
- constructor() {
420
- super({
421
- id: PASTE_CELL_ABOVE_COMMAND_ID,
422
- title: ( localizeWithPath(
423
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
424
- 'notebookActions.pasteAbove',
425
- "Paste Cell Above"
426
- )),
427
- keybinding: {
428
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
429
- primary: 2048 | 1024 | 52 ,
430
- weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
431
- },
432
- });
433
- }
434
- async runWithContext(accessor, context) {
435
- const notebookService = accessor.get(INotebookService);
436
- const pasteCells = notebookService.getToCopy();
437
- const editor = context.notebookEditor;
438
- const textModel = editor.textModel;
439
- if (editor.isReadOnly) {
440
- return;
441
- }
442
- if (!pasteCells) {
443
- return;
444
- }
445
- const originalState = {
446
- kind: SelectionStateType.Index,
447
- focus: editor.getFocus(),
448
- selections: editor.getSelections()
449
- };
450
- const currCellIndex = context.notebookEditor.getCellIndex(context.cell);
451
- const newFocusIndex = currCellIndex;
452
- textModel.applyEdits([
453
- {
454
- editType: 1 ,
455
- index: currCellIndex,
456
- count: 0,
457
- cells: ( pasteCells.items.map(cell => cloneNotebookCellTextModel(cell)))
458
- }
459
- ], true, originalState, () => ({
460
- kind: SelectionStateType.Index,
461
- focus: { start: newFocusIndex, end: newFocusIndex + 1 },
462
- selections: [{ start: newFocusIndex, end: newFocusIndex + pasteCells.items.length }]
463
- }), undefined, true);
464
- }
465
- });
466
- registerAction2(class extends Action2 {
467
- constructor() {
468
- super({
469
- id: 'workbench.action.toggleNotebookClipboardLog',
470
- title: ( localize2WithPath(
471
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
472
- 'toggleNotebookClipboardLog',
473
- 'Toggle Notebook Clipboard Troubleshooting'
474
- )),
475
- category: Categories.Developer,
476
- f1: true
477
- });
478
- }
479
- run(accessor) {
480
- toggleLogging();
481
- if (_logging) {
482
- const commandService = accessor.get(ICommandService);
483
- commandService.executeCommand(showWindowLogActionId);
484
- }
485
- }
486
- });
487
-
488
- export { NotebookClipboardContribution, runCopyCells, runCutCells, runPasteCells };
@@ -1,106 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
3
- import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
4
- import { Schemas } from 'vscode/vscode/vs/base/common/network';
5
- import { isEqual } from 'vscode/vscode/vs/base/common/resources';
6
- import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
7
- import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
8
- import { IDebugService } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
9
- import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
10
- import { NotebookCellsChangeType, CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
11
- import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
12
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
13
-
14
- let NotebookBreakpoints = class NotebookBreakpoints extends Disposable {
15
- constructor(_debugService, _notebookService, _editorService) {
16
- super();
17
- this._debugService = _debugService;
18
- this._editorService = _editorService;
19
- const listeners = ( new ResourceMap());
20
- this._register(_notebookService.onWillAddNotebookDocument(model => {
21
- listeners.set(model.uri, model.onWillAddRemoveCells(e => {
22
- const debugModel = this._debugService.getModel();
23
- if (!debugModel.getBreakpoints().length) {
24
- return;
25
- }
26
- if (e.rawEvent.kind !== NotebookCellsChangeType.ModelChange) {
27
- return;
28
- }
29
- for (const change of e.rawEvent.changes) {
30
- const [start, deleteCount] = change;
31
- if (deleteCount > 0) {
32
- const deleted = model.cells.slice(start, start + deleteCount);
33
- for (const deletedCell of deleted) {
34
- const cellBps = debugModel.getBreakpoints({ uri: deletedCell.uri });
35
- cellBps.forEach(cellBp => this._debugService.removeBreakpoints(cellBp.getId()));
36
- }
37
- }
38
- }
39
- }));
40
- }));
41
- this._register(_notebookService.onWillRemoveNotebookDocument(model => {
42
- this.updateBreakpoints(model);
43
- listeners.get(model.uri)?.dispose();
44
- listeners.delete(model.uri);
45
- }));
46
- this._register(this._debugService.getModel().onDidChangeBreakpoints(e => {
47
- const newCellBp = e?.added?.find(bp => 'uri' in bp && bp.uri.scheme === Schemas.vscodeNotebookCell);
48
- if (newCellBp) {
49
- const parsed = CellUri.parse(newCellBp.uri);
50
- if (!parsed) {
51
- return;
52
- }
53
- const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
54
- if (!editor || !editor.hasModel() || ( editor.textModel.uri.toString()) !== ( parsed.notebook.toString())) {
55
- return;
56
- }
57
- const cell = editor.getCellByHandle(parsed.handle);
58
- if (!cell) {
59
- return;
60
- }
61
- editor.focusElement(cell);
62
- }
63
- }));
64
- }
65
- updateBreakpoints(model) {
66
- const bps = this._debugService.getModel().getBreakpoints();
67
- if (!bps.length || !model.cells.length) {
68
- return;
69
- }
70
- const idxMap = ( new ResourceMap());
71
- model.cells.forEach((cell, i) => {
72
- idxMap.set(cell.uri, i);
73
- });
74
- bps.forEach(bp => {
75
- const idx = idxMap.get(bp.uri);
76
- if (typeof idx !== 'number') {
77
- return;
78
- }
79
- const notebook = CellUri.parse(bp.uri)?.notebook;
80
- if (!notebook) {
81
- return;
82
- }
83
- const newUri = CellUri.generate(notebook, idx);
84
- if (isEqual(newUri, bp.uri)) {
85
- return;
86
- }
87
- this._debugService.removeBreakpoints(bp.getId());
88
- this._debugService.addBreakpoints(newUri, [
89
- {
90
- column: bp.column,
91
- condition: bp.condition,
92
- enabled: bp.enabled,
93
- hitCondition: bp.hitCondition,
94
- logMessage: bp.logMessage,
95
- lineNumber: bp.lineNumber
96
- }
97
- ]);
98
- });
99
- }
100
- };
101
- NotebookBreakpoints = ( __decorate([
102
- ( __param(0, IDebugService)),
103
- ( __param(1, INotebookService)),
104
- ( __param(2, IEditorService))
105
- ], NotebookBreakpoints));
106
- ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(NotebookBreakpoints, 3 );
@@ -1,67 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
- import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
3
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { URI } from 'vscode/vscode/vs/base/common/uri';
5
- import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
6
- import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
7
- import { IDebugService } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
8
- import { CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
9
- import { CellExecutionUpdateType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionService';
10
- import { INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
11
-
12
- let NotebookCellPausing = class NotebookCellPausing extends Disposable {
13
- constructor(_debugService, _notebookExecutionStateService) {
14
- super();
15
- this._debugService = _debugService;
16
- this._notebookExecutionStateService = _notebookExecutionStateService;
17
- this._pausedCells = ( new Set());
18
- this._register(_debugService.getModel().onDidChangeCallStack(() => {
19
- this.onDidChangeCallStack(true);
20
- this._scheduler.schedule();
21
- }));
22
- this._scheduler = this._register(( new RunOnceScheduler(() => this.onDidChangeCallStack(false), 2000)));
23
- }
24
- async onDidChangeCallStack(fallBackOnStaleCallstack) {
25
- const newPausedCells = ( new Set());
26
- for (const session of this._debugService.getModel().getSessions()) {
27
- for (const thread of session.getAllThreads()) {
28
- let callStack = thread.getCallStack();
29
- if (fallBackOnStaleCallstack && !callStack.length) {
30
- callStack = thread.getStaleCallStack();
31
- }
32
- callStack.forEach(sf => {
33
- const parsed = CellUri.parse(sf.source.uri);
34
- if (parsed) {
35
- newPausedCells.add(( sf.source.uri.toString()));
36
- this.editIsPaused(sf.source.uri, true);
37
- }
38
- });
39
- }
40
- }
41
- for (const uri of this._pausedCells) {
42
- if (!( newPausedCells.has(uri))) {
43
- this.editIsPaused(( URI.parse(uri)), false);
44
- this._pausedCells.delete(uri);
45
- }
46
- }
47
- newPausedCells.forEach(cell => this._pausedCells.add(cell));
48
- }
49
- editIsPaused(cellUri, isPaused) {
50
- const parsed = CellUri.parse(cellUri);
51
- if (parsed) {
52
- const exeState = this._notebookExecutionStateService.getCellExecution(cellUri);
53
- if (exeState && (exeState.isPaused !== isPaused || !exeState.didPause)) {
54
- exeState.update([{
55
- editType: CellExecutionUpdateType.ExecutionState,
56
- didPause: true,
57
- isPaused
58
- }]);
59
- }
60
- }
61
- }
62
- };
63
- NotebookCellPausing = ( __decorate([
64
- ( __param(0, IDebugService)),
65
- ( __param(1, INotebookExecutionStateService))
66
- ], NotebookCellPausing));
67
- ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(NotebookCellPausing, 3 );