@codingame/monaco-vscode-notebook-service-override 4.0.0 → 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 (77) hide show
  1. package/notebook.js +12 -12
  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 -10
  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 -391
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +0 -109
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +0 -173
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +0 -544
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +0 -106
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +0 -67
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +0 -165
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +0 -67
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +0 -320
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +0 -72
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +0 -6
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +0 -168
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +0 -209
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +0 -84
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +0 -82
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +0 -67
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +0 -101
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +0 -393
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +0 -5
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +0 -97
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +0 -120
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +0 -60
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +0 -150
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +0 -656
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +0 -77
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +0 -517
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +0 -159
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +0 -56
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +0 -94
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +0 -51
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +0 -652
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +0 -721
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -351
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +0 -315
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +0 -199
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -47
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1297
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -284
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -563
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -115
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -39
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +0 -6
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +0 -313
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -911
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -13
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -395
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -185
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +0 -1187
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +0 -159
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +0 -451
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +0 -192
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +0 -106
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +0 -510
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +0 -130
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +0 -341
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +0 -111
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +0 -28
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +0 -65
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +0 -641
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +0 -200
  67. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +0 -90
  68. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +0 -1002
  69. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +0 -103
  70. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +0 -203
  71. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +0 -80
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +0 -98
  73. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +0 -89
  74. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +0 -386
  75. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +0 -408
  76. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +0 -144
  77. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +0 -129
@@ -1,544 +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, NOTEBOOK_OUTPUT_FOCUSED } 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, NOTEBOOK_OUTPUT_WEBVIEW_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 getFocusedEditor(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 view = editor.getViewModel();
51
- if (view && view.viewCells.every(cell => !cell.outputIsFocused && !cell.outputIsHovered)) {
52
- return;
53
- }
54
- return { editor, loggerService };
55
- }
56
- function getFocusedWebviewDelegate(accessor) {
57
- const result = getFocusedEditor(accessor);
58
- if (!result) {
59
- return;
60
- }
61
- const webview = result.editor.getInnerWebview();
62
- _log(result.loggerService, '[Revive Webview] Notebook editor backlayer webview is focused');
63
- return webview;
64
- }
65
- function withWebview(accessor, f) {
66
- const webview = getFocusedWebviewDelegate(accessor);
67
- if (webview) {
68
- f(webview);
69
- return true;
70
- }
71
- return false;
72
- }
73
- function withEditor(accessor, f) {
74
- const result = getFocusedEditor(accessor);
75
- return result ? f(result.editor) : false;
76
- }
77
- const PRIORITY = 105;
78
- UndoCommand.addImplementation(PRIORITY, 'notebook-webview', accessor => {
79
- return withWebview(accessor, webview => webview.undo());
80
- });
81
- RedoCommand.addImplementation(PRIORITY, 'notebook-webview', accessor => {
82
- return withWebview(accessor, webview => webview.redo());
83
- });
84
- CopyAction?.addImplementation(PRIORITY, 'notebook-webview', accessor => {
85
- return withWebview(accessor, webview => webview.copy());
86
- });
87
- PasteAction?.addImplementation(PRIORITY, 'notebook-webview', accessor => {
88
- return withWebview(accessor, webview => webview.paste());
89
- });
90
- CutAction?.addImplementation(PRIORITY, 'notebook-webview', accessor => {
91
- return withWebview(accessor, webview => webview.cut());
92
- });
93
- function runPasteCells(editor, activeCell, pasteCells) {
94
- if (!editor.hasModel()) {
95
- return false;
96
- }
97
- const textModel = editor.textModel;
98
- if (editor.isReadOnly) {
99
- return false;
100
- }
101
- const originalState = {
102
- kind: SelectionStateType.Index,
103
- focus: editor.getFocus(),
104
- selections: editor.getSelections()
105
- };
106
- if (activeCell) {
107
- const currCellIndex = editor.getCellIndex(activeCell);
108
- const newFocusIndex = typeof currCellIndex === 'number' ? currCellIndex + 1 : 0;
109
- textModel.applyEdits([
110
- {
111
- editType: 1 ,
112
- index: newFocusIndex,
113
- count: 0,
114
- cells: ( pasteCells.items.map(cell => cloneNotebookCellTextModel(cell)))
115
- }
116
- ], true, originalState, () => ({
117
- kind: SelectionStateType.Index,
118
- focus: { start: newFocusIndex, end: newFocusIndex + 1 },
119
- selections: [{ start: newFocusIndex, end: newFocusIndex + pasteCells.items.length }]
120
- }), undefined, true);
121
- }
122
- else {
123
- if (editor.getLength() !== 0) {
124
- return false;
125
- }
126
- textModel.applyEdits([
127
- {
128
- editType: 1 ,
129
- index: 0,
130
- count: 0,
131
- cells: ( pasteCells.items.map(cell => cloneNotebookCellTextModel(cell)))
132
- }
133
- ], true, originalState, () => ({
134
- kind: SelectionStateType.Index,
135
- focus: { start: 0, end: 1 },
136
- selections: [{ start: 1, end: pasteCells.items.length + 1 }]
137
- }), undefined, true);
138
- }
139
- return true;
140
- }
141
- function runCopyCells(accessor, editor, targetCell) {
142
- if (!editor.hasModel()) {
143
- return false;
144
- }
145
- if (editor.hasOutputTextSelection()) {
146
- getWindow(editor.getDomNode()).document.execCommand('copy');
147
- return true;
148
- }
149
- const clipboardService = accessor.get(IClipboardService);
150
- const notebookService = accessor.get(INotebookService);
151
- const selections = editor.getSelections();
152
- if (targetCell) {
153
- const targetCellIndex = editor.getCellIndex(targetCell);
154
- const containingSelection = selections.find(selection => selection.start <= targetCellIndex && targetCellIndex < selection.end);
155
- if (!containingSelection) {
156
- clipboardService.writeText(targetCell.getText());
157
- notebookService.setToCopy([targetCell.model], true);
158
- return true;
159
- }
160
- }
161
- const selectionRanges = expandCellRangesWithHiddenCells(editor, editor.getSelections());
162
- const selectedCells = cellRangeToViewCells(editor, selectionRanges);
163
- if (!selectedCells.length) {
164
- return false;
165
- }
166
- clipboardService.writeText(( selectedCells.map(cell => cell.getText())).join('\n'));
167
- notebookService.setToCopy(( selectedCells.map(cell => cell.model)), true);
168
- return true;
169
- }
170
- function runCutCells(accessor, editor, targetCell) {
171
- if (!editor.hasModel() || editor.isReadOnly) {
172
- return false;
173
- }
174
- const textModel = editor.textModel;
175
- const clipboardService = accessor.get(IClipboardService);
176
- const notebookService = accessor.get(INotebookService);
177
- const selections = editor.getSelections();
178
- if (targetCell) {
179
- const targetCellIndex = editor.getCellIndex(targetCell);
180
- const containingSelection = selections.find(selection => selection.start <= targetCellIndex && targetCellIndex < selection.end);
181
- if (!containingSelection) {
182
- clipboardService.writeText(targetCell.getText());
183
- const focus = editor.getFocus();
184
- const newFocus = focus.end <= targetCellIndex ? focus : { start: focus.start - 1, end: focus.end - 1 };
185
- const newSelections = ( selections.map(
186
- selection => (selection.end <= targetCellIndex ? selection : { start: selection.start - 1, end: selection.end - 1 })
187
- ));
188
- textModel.applyEdits([
189
- { editType: 1 , index: targetCellIndex, count: 1, cells: [] }
190
- ], true, { kind: SelectionStateType.Index, focus: editor.getFocus(), selections: selections }, () => ({ kind: SelectionStateType.Index, focus: newFocus, selections: newSelections }), undefined, true);
191
- notebookService.setToCopy([targetCell.model], false);
192
- return true;
193
- }
194
- }
195
- const focus = editor.getFocus();
196
- const containingSelection = selections.find(selection => selection.start <= focus.start && focus.end <= selection.end);
197
- if (!containingSelection) {
198
- const targetCell = editor.cellAt(focus.start);
199
- clipboardService.writeText(targetCell.getText());
200
- const newFocus = focus.end === editor.getLength() ? { start: focus.start - 1, end: focus.end - 1 } : focus;
201
- const newSelections = ( selections.map(
202
- selection => (selection.end <= focus.start ? selection : { start: selection.start - 1, end: selection.end - 1 })
203
- ));
204
- textModel.applyEdits([
205
- { editType: 1 , index: focus.start, count: 1, cells: [] }
206
- ], true, { kind: SelectionStateType.Index, focus: editor.getFocus(), selections: selections }, () => ({ kind: SelectionStateType.Index, focus: newFocus, selections: newSelections }), undefined, true);
207
- notebookService.setToCopy([targetCell.model], false);
208
- return true;
209
- }
210
- const selectionRanges = expandCellRangesWithHiddenCells(editor, editor.getSelections());
211
- const selectedCells = cellRangeToViewCells(editor, selectionRanges);
212
- if (!selectedCells.length) {
213
- return false;
214
- }
215
- clipboardService.writeText(( selectedCells.map(cell => cell.getText())).join('\n'));
216
- const edits = ( selectionRanges.map(
217
- range => ({ editType: 1 , index: range.start, count: range.end - range.start, cells: [] })
218
- ));
219
- const firstSelectIndex = selectionRanges[0].start;
220
- const newFocusedCellIndex = firstSelectIndex < textModel.cells.length - 1
221
- ? firstSelectIndex
222
- : Math.max(textModel.cells.length - 2, 0);
223
- textModel.applyEdits(edits, true, { kind: SelectionStateType.Index, focus: editor.getFocus(), selections: selectionRanges }, () => {
224
- return {
225
- kind: SelectionStateType.Index,
226
- focus: { start: newFocusedCellIndex, end: newFocusedCellIndex + 1 },
227
- selections: [{ start: newFocusedCellIndex, end: newFocusedCellIndex + 1 }]
228
- };
229
- }, undefined, true);
230
- notebookService.setToCopy(( selectedCells.map(cell => cell.model)), false);
231
- return true;
232
- }
233
- let NotebookClipboardContribution = class NotebookClipboardContribution extends Disposable {
234
- static { this.ID = 'workbench.contrib.notebookClipboard'; }
235
- constructor(_editorService) {
236
- super();
237
- this._editorService = _editorService;
238
- const PRIORITY = 105;
239
- if (CopyAction) {
240
- this._register(CopyAction.addImplementation(PRIORITY, 'notebook-clipboard', accessor => {
241
- return this.runCopyAction(accessor);
242
- }));
243
- }
244
- if (PasteAction) {
245
- this._register(PasteAction.addImplementation(PRIORITY, 'notebook-clipboard', accessor => {
246
- return this.runPasteAction(accessor);
247
- }));
248
- }
249
- if (CutAction) {
250
- this._register(CutAction.addImplementation(PRIORITY, 'notebook-clipboard', accessor => {
251
- return this.runCutAction(accessor);
252
- }));
253
- }
254
- }
255
- _getContext() {
256
- const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
257
- const activeCell = editor?.getActiveCell();
258
- return {
259
- editor,
260
- activeCell
261
- };
262
- }
263
- _focusInsideEmebedMonaco(editor) {
264
- const windowSelection = getWindow(editor.getDomNode()).getSelection();
265
- if (windowSelection?.rangeCount !== 1) {
266
- return false;
267
- }
268
- const activeSelection = windowSelection.getRangeAt(0);
269
- if (activeSelection.startContainer === activeSelection.endContainer && activeSelection.endOffset - activeSelection.startOffset === 0) {
270
- return false;
271
- }
272
- let container = activeSelection.commonAncestorContainer;
273
- const body = editor.getDomNode();
274
- if (!body.contains(container)) {
275
- return false;
276
- }
277
- while (container
278
- &&
279
- container !== body) {
280
- if (container.classList && container.classList.contains('monaco-editor')) {
281
- return true;
282
- }
283
- container = container.parentNode;
284
- }
285
- return false;
286
- }
287
- runCopyAction(accessor) {
288
- const loggerService = accessor.get(ILogService);
289
- const activeElement = getActiveElement();
290
- if (activeElement instanceof HTMLElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) {
291
- _log(loggerService, '[NotebookEditor] focus is on input or textarea element, bypass');
292
- return false;
293
- }
294
- const { editor } = this._getContext();
295
- if (!editor) {
296
- _log(loggerService, '[NotebookEditor] no active notebook editor, bypass');
297
- return false;
298
- }
299
- if (!isAncestor(activeElement, editor.getDomNode())) {
300
- _log(loggerService, '[NotebookEditor] focus is outside of the notebook editor, bypass');
301
- return false;
302
- }
303
- if (this._focusInsideEmebedMonaco(editor)) {
304
- _log(loggerService, '[NotebookEditor] focus is on embed monaco editor, bypass');
305
- return false;
306
- }
307
- _log(loggerService, '[NotebookEditor] run copy actions on notebook model');
308
- return runCopyCells(accessor, editor, undefined);
309
- }
310
- runPasteAction(accessor) {
311
- const activeElement = getActiveElement();
312
- if (activeElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) {
313
- return false;
314
- }
315
- const notebookService = accessor.get(INotebookService);
316
- const pasteCells = notebookService.getToCopy();
317
- if (!pasteCells) {
318
- return false;
319
- }
320
- const { editor, activeCell } = this._getContext();
321
- if (!editor) {
322
- return false;
323
- }
324
- return runPasteCells(editor, activeCell, pasteCells);
325
- }
326
- runCutAction(accessor) {
327
- const activeElement = getActiveElement();
328
- if (activeElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) {
329
- return false;
330
- }
331
- const { editor } = this._getContext();
332
- if (!editor) {
333
- return false;
334
- }
335
- return runCutCells(accessor, editor, undefined);
336
- }
337
- };
338
- NotebookClipboardContribution = ( __decorate([
339
- ( __param(0, IEditorService))
340
- ], NotebookClipboardContribution));
341
- registerWorkbenchContribution2(NotebookClipboardContribution.ID, NotebookClipboardContribution, 2 );
342
- const COPY_CELL_COMMAND_ID = 'notebook.cell.copy';
343
- const CUT_CELL_COMMAND_ID = 'notebook.cell.cut';
344
- const PASTE_CELL_COMMAND_ID = 'notebook.cell.paste';
345
- const PASTE_CELL_ABOVE_COMMAND_ID = 'notebook.cell.pasteAbove';
346
- registerAction2(class extends NotebookCellAction {
347
- constructor() {
348
- super({
349
- id: COPY_CELL_COMMAND_ID,
350
- title: ( localizeWithPath(
351
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
352
- 'notebookActions.copy',
353
- "Copy Cell"
354
- )),
355
- menu: {
356
- id: MenuId.NotebookCellTitle,
357
- when: NOTEBOOK_EDITOR_FOCUSED,
358
- group: "1_copy" ,
359
- order: 2,
360
- },
361
- keybinding: isNative ? undefined : {
362
- primary: 2048 | 33 ,
363
- win: { primary: 2048 | 33 , secondary: [2048 | 19 ] },
364
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
365
- weight: 200
366
- }
367
- });
368
- }
369
- async runWithContext(accessor, context) {
370
- runCopyCells(accessor, context.notebookEditor, context.cell);
371
- }
372
- });
373
- registerAction2(class extends NotebookCellAction {
374
- constructor() {
375
- super({
376
- id: CUT_CELL_COMMAND_ID,
377
- title: ( localizeWithPath(
378
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
379
- 'notebookActions.cut',
380
- "Cut Cell"
381
- )),
382
- menu: {
383
- id: MenuId.NotebookCellTitle,
384
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE)),
385
- group: "1_copy" ,
386
- order: 1,
387
- },
388
- keybinding: isNative ? undefined : {
389
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
390
- primary: 2048 | 54 ,
391
- win: { primary: 2048 | 54 , secondary: [1024 | 20 ] },
392
- weight: 200
393
- }
394
- });
395
- }
396
- async runWithContext(accessor, context) {
397
- runCutCells(accessor, context.notebookEditor, context.cell);
398
- }
399
- });
400
- registerAction2(class extends NotebookAction {
401
- constructor() {
402
- super({
403
- id: PASTE_CELL_COMMAND_ID,
404
- title: ( localizeWithPath(
405
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
406
- 'notebookActions.paste',
407
- "Paste Cell"
408
- )),
409
- menu: {
410
- id: MenuId.NotebookCellTitle,
411
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE)),
412
- group: "1_copy" ,
413
- order: 3,
414
- },
415
- keybinding: isNative ? undefined : {
416
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
417
- primary: 2048 | 52 ,
418
- win: { primary: 2048 | 52 , secondary: [1024 | 19 ] },
419
- linux: { primary: 2048 | 52 , secondary: [1024 | 19 ] },
420
- weight: 100
421
- }
422
- });
423
- }
424
- async runWithContext(accessor, context) {
425
- const notebookService = accessor.get(INotebookService);
426
- const pasteCells = notebookService.getToCopy();
427
- if (!context.notebookEditor.hasModel() || context.notebookEditor.isReadOnly) {
428
- return;
429
- }
430
- if (!pasteCells) {
431
- return;
432
- }
433
- runPasteCells(context.notebookEditor, context.cell, pasteCells);
434
- }
435
- });
436
- registerAction2(class extends NotebookCellAction {
437
- constructor() {
438
- super({
439
- id: PASTE_CELL_ABOVE_COMMAND_ID,
440
- title: ( localizeWithPath(
441
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
442
- 'notebookActions.pasteAbove',
443
- "Paste Cell Above"
444
- )),
445
- keybinding: {
446
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
447
- primary: 2048 | 1024 | 52 ,
448
- weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
449
- },
450
- });
451
- }
452
- async runWithContext(accessor, context) {
453
- const notebookService = accessor.get(INotebookService);
454
- const pasteCells = notebookService.getToCopy();
455
- const editor = context.notebookEditor;
456
- const textModel = editor.textModel;
457
- if (editor.isReadOnly) {
458
- return;
459
- }
460
- if (!pasteCells) {
461
- return;
462
- }
463
- const originalState = {
464
- kind: SelectionStateType.Index,
465
- focus: editor.getFocus(),
466
- selections: editor.getSelections()
467
- };
468
- const currCellIndex = context.notebookEditor.getCellIndex(context.cell);
469
- const newFocusIndex = currCellIndex;
470
- textModel.applyEdits([
471
- {
472
- editType: 1 ,
473
- index: currCellIndex,
474
- count: 0,
475
- cells: ( pasteCells.items.map(cell => cloneNotebookCellTextModel(cell)))
476
- }
477
- ], true, originalState, () => ({
478
- kind: SelectionStateType.Index,
479
- focus: { start: newFocusIndex, end: newFocusIndex + 1 },
480
- selections: [{ start: newFocusIndex, end: newFocusIndex + pasteCells.items.length }]
481
- }), undefined, true);
482
- }
483
- });
484
- registerAction2(class extends Action2 {
485
- constructor() {
486
- super({
487
- id: 'workbench.action.toggleNotebookClipboardLog',
488
- title: ( localize2WithPath(
489
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
490
- 'toggleNotebookClipboardLog',
491
- 'Toggle Notebook Clipboard Troubleshooting'
492
- )),
493
- category: Categories.Developer,
494
- f1: true
495
- });
496
- }
497
- run(accessor) {
498
- toggleLogging();
499
- if (_logging) {
500
- const commandService = accessor.get(ICommandService);
501
- commandService.executeCommand(showWindowLogActionId);
502
- }
503
- }
504
- });
505
- registerAction2(class extends NotebookCellAction {
506
- constructor() {
507
- super({
508
- id: 'notebook.cell.output.selectAll',
509
- title: ( localizeWithPath(
510
- 'vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard',
511
- 'notebook.cell.output.selectAll',
512
- "Select All"
513
- )),
514
- keybinding: {
515
- primary: 2048 | 31 ,
516
- when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED)),
517
- weight: NOTEBOOK_OUTPUT_WEBVIEW_ACTION_WEIGHT
518
- }
519
- });
520
- }
521
- async runWithContext(accessor, _context) {
522
- withEditor(accessor, editor => {
523
- if (!editor.hasEditorFocus()) {
524
- return false;
525
- }
526
- if (editor.hasEditorFocus() && !editor.hasWebviewFocus()) {
527
- return true;
528
- }
529
- const cell = editor.getActiveCell();
530
- if (!cell || !cell.outputIsFocused || !editor.hasWebviewFocus()) {
531
- return true;
532
- }
533
- if (cell.inputInOutputIsFocused) {
534
- editor.selectInputContents(cell);
535
- }
536
- else {
537
- editor.selectOutputContent(cell);
538
- }
539
- return true;
540
- });
541
- }
542
- });
543
-
544
- 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 );