@codingame/monaco-vscode-notebook-service-override 5.2.0 → 6.0.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.
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +26 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +549 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +133 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +58 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +6 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +29 -27
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +10 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +27 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +32 -24
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +5 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +42 -40
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +77 -57
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +184 -99
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +56 -112
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +31 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +10 -14
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +6 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +3 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +10 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +7 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +6 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +21 -15
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +8 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +6 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +88 -86
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +94 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +73 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +3 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +7 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +5 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +6 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +44 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +34 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +5 -3
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +67 -53
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +11 -3
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +11 -10
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +3 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +5 -3
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +15 -12
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +4 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +0 -156
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
import { KeyMod, KeyCode, KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
2
|
+
import { Mimes } from 'vscode/vscode/vs/base/common/mime';
|
|
3
|
+
import { IBulkEditService, ResourceTextEdit } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
|
|
4
|
+
import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
5
|
+
import { registerAction2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
6
|
+
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
7
|
+
import { InputFocusedContext, InputFocusedContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkeys';
|
|
8
|
+
import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
|
|
9
|
+
import { ResourceNotebookCellEdit } from 'vscode/vscode/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits';
|
|
10
|
+
import { moveCellRange, copyCellRange, computeCellLinesContents, joinCellsWithSurrounds, joinSelectedCells, changeCellToKind } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/cellOperations';
|
|
11
|
+
import { NotebookCellAction, CellOverflowToolbarGroups, CellToolbarOrder, CELL_TITLE_CELL_GROUP_ID, NotebookMultiCellAction, parseMultiCellExecutionArgs, cellExecutionArgs } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
|
|
12
|
+
import { CellFocusMode, EXPAND_CELL_INPUT_COMMAND_ID, EXPAND_CELL_OUTPUT_COMMAND_ID } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
13
|
+
import { NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE, NOTEBOOK_CELL_INPUT_COLLAPSED, NOTEBOOK_OUTPUT_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_CELL_TYPE, NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_OUTPUT_COLLAPSED, NOTEBOOK_CELL_HAS_OUTPUTS } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
|
|
14
|
+
import { moveUpIcon, moveDownIcon, splitCellIcon } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
|
|
15
|
+
import { CellEditType, CellKind, NotebookSetting } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
16
|
+
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
|
|
17
|
+
import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
|
|
18
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
19
|
+
|
|
20
|
+
const _moduleId = "vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands";
|
|
21
|
+
const MOVE_CELL_UP_COMMAND_ID = 'notebook.cell.moveUp';
|
|
22
|
+
const MOVE_CELL_DOWN_COMMAND_ID = 'notebook.cell.moveDown';
|
|
23
|
+
const COPY_CELL_UP_COMMAND_ID = 'notebook.cell.copyUp';
|
|
24
|
+
const COPY_CELL_DOWN_COMMAND_ID = 'notebook.cell.copyDown';
|
|
25
|
+
registerAction2(class extends NotebookCellAction {
|
|
26
|
+
constructor() {
|
|
27
|
+
super({
|
|
28
|
+
id: MOVE_CELL_UP_COMMAND_ID,
|
|
29
|
+
title: ( localize2WithPath(_moduleId, 0, "Move Cell Up")),
|
|
30
|
+
icon: moveUpIcon,
|
|
31
|
+
keybinding: {
|
|
32
|
+
primary: KeyMod.Alt | KeyCode.UpArrow,
|
|
33
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, (InputFocusedContext.toNegated())))),
|
|
34
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
35
|
+
},
|
|
36
|
+
menu: {
|
|
37
|
+
id: MenuId.NotebookCellTitle,
|
|
38
|
+
when: ( (ContextKeyExpr.equals('config.notebook.dragAndDropEnabled', false))),
|
|
39
|
+
group: CellOverflowToolbarGroups.Edit,
|
|
40
|
+
order: 14
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async runWithContext(accessor, context) {
|
|
45
|
+
return moveCellRange(context, 'up');
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
registerAction2(class extends NotebookCellAction {
|
|
49
|
+
constructor() {
|
|
50
|
+
super({
|
|
51
|
+
id: MOVE_CELL_DOWN_COMMAND_ID,
|
|
52
|
+
title: ( localize2WithPath(_moduleId, 1, "Move Cell Down")),
|
|
53
|
+
icon: moveDownIcon,
|
|
54
|
+
keybinding: {
|
|
55
|
+
primary: KeyMod.Alt | KeyCode.DownArrow,
|
|
56
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, (InputFocusedContext.toNegated())))),
|
|
57
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
58
|
+
},
|
|
59
|
+
menu: {
|
|
60
|
+
id: MenuId.NotebookCellTitle,
|
|
61
|
+
when: ( (ContextKeyExpr.equals('config.notebook.dragAndDropEnabled', false))),
|
|
62
|
+
group: CellOverflowToolbarGroups.Edit,
|
|
63
|
+
order: 14
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async runWithContext(accessor, context) {
|
|
68
|
+
return moveCellRange(context, 'down');
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
registerAction2(class extends NotebookCellAction {
|
|
72
|
+
constructor() {
|
|
73
|
+
super({
|
|
74
|
+
id: COPY_CELL_UP_COMMAND_ID,
|
|
75
|
+
title: ( localize2WithPath(_moduleId, 2, "Copy Cell Up")),
|
|
76
|
+
keybinding: {
|
|
77
|
+
primary: KeyMod.Alt | KeyMod.Shift | KeyCode.UpArrow,
|
|
78
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, (InputFocusedContext.toNegated())))),
|
|
79
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async runWithContext(accessor, context) {
|
|
84
|
+
return copyCellRange(context, 'up');
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
registerAction2(class extends NotebookCellAction {
|
|
88
|
+
constructor() {
|
|
89
|
+
super({
|
|
90
|
+
id: COPY_CELL_DOWN_COMMAND_ID,
|
|
91
|
+
title: ( localize2WithPath(_moduleId, 3, "Copy Cell Down")),
|
|
92
|
+
keybinding: {
|
|
93
|
+
primary: KeyMod.Alt | KeyMod.Shift | KeyCode.DownArrow,
|
|
94
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, (InputFocusedContext.toNegated())))),
|
|
95
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
96
|
+
},
|
|
97
|
+
menu: {
|
|
98
|
+
id: MenuId.NotebookCellTitle,
|
|
99
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE))),
|
|
100
|
+
group: CellOverflowToolbarGroups.Edit,
|
|
101
|
+
order: 13
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
async runWithContext(accessor, context) {
|
|
106
|
+
return copyCellRange(context, 'down');
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
const SPLIT_CELL_COMMAND_ID = 'notebook.cell.split';
|
|
110
|
+
const JOIN_SELECTED_CELLS_COMMAND_ID = 'notebook.cell.joinSelected';
|
|
111
|
+
const JOIN_CELL_ABOVE_COMMAND_ID = 'notebook.cell.joinAbove';
|
|
112
|
+
const JOIN_CELL_BELOW_COMMAND_ID = 'notebook.cell.joinBelow';
|
|
113
|
+
registerAction2(class extends NotebookCellAction {
|
|
114
|
+
constructor() {
|
|
115
|
+
super({
|
|
116
|
+
id: SPLIT_CELL_COMMAND_ID,
|
|
117
|
+
title: ( localize2WithPath(_moduleId, 4, "Split Cell")),
|
|
118
|
+
menu: {
|
|
119
|
+
id: MenuId.NotebookCellTitle,
|
|
120
|
+
when: ( (ContextKeyExpr.and(
|
|
121
|
+
NOTEBOOK_EDITOR_EDITABLE,
|
|
122
|
+
NOTEBOOK_CELL_EDITABLE,
|
|
123
|
+
(NOTEBOOK_CELL_INPUT_COLLAPSED.toNegated())
|
|
124
|
+
))),
|
|
125
|
+
order: CellToolbarOrder.SplitCell,
|
|
126
|
+
group: CELL_TITLE_CELL_GROUP_ID
|
|
127
|
+
},
|
|
128
|
+
icon: splitCellIcon,
|
|
129
|
+
keybinding: {
|
|
130
|
+
when: ( (ContextKeyExpr.and(
|
|
131
|
+
NOTEBOOK_EDITOR_FOCUSED,
|
|
132
|
+
NOTEBOOK_EDITOR_EDITABLE,
|
|
133
|
+
NOTEBOOK_CELL_EDITABLE,
|
|
134
|
+
EditorContextKeys.editorTextFocus
|
|
135
|
+
))),
|
|
136
|
+
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Backslash),
|
|
137
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async runWithContext(accessor, context) {
|
|
142
|
+
if (context.notebookEditor.isReadOnly) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const bulkEditService = accessor.get(IBulkEditService);
|
|
146
|
+
const cell = context.cell;
|
|
147
|
+
const index = context.notebookEditor.getCellIndex(cell);
|
|
148
|
+
const splitPoints = cell.focusMode === CellFocusMode.Container ? [{ lineNumber: 1, column: 1 }] : cell.getSelectionsStartPosition();
|
|
149
|
+
if (splitPoints && splitPoints.length > 0) {
|
|
150
|
+
await cell.resolveTextModel();
|
|
151
|
+
if (!cell.hasModel()) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const newLinesContents = computeCellLinesContents(cell, splitPoints);
|
|
155
|
+
if (newLinesContents) {
|
|
156
|
+
const language = cell.language;
|
|
157
|
+
const kind = cell.cellKind;
|
|
158
|
+
const mime = cell.mime;
|
|
159
|
+
const textModel = await cell.resolveTextModel();
|
|
160
|
+
await bulkEditService.apply([
|
|
161
|
+
( (new ResourceTextEdit(
|
|
162
|
+
cell.uri,
|
|
163
|
+
{ range: textModel.getFullModelRange(), text: newLinesContents[0] }
|
|
164
|
+
))),
|
|
165
|
+
( (new ResourceNotebookCellEdit(context.notebookEditor.textModel.uri, {
|
|
166
|
+
editType: CellEditType.Replace,
|
|
167
|
+
index: index + 1,
|
|
168
|
+
count: 0,
|
|
169
|
+
cells: ( (newLinesContents.slice(1).map(line => ({
|
|
170
|
+
cellKind: kind,
|
|
171
|
+
language,
|
|
172
|
+
mime,
|
|
173
|
+
source: line,
|
|
174
|
+
outputs: [],
|
|
175
|
+
metadata: {}
|
|
176
|
+
}))))
|
|
177
|
+
})))
|
|
178
|
+
], { quotableLabel: 'Split Notebook Cell' });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
registerAction2(class extends NotebookCellAction {
|
|
184
|
+
constructor() {
|
|
185
|
+
super({
|
|
186
|
+
id: JOIN_CELL_ABOVE_COMMAND_ID,
|
|
187
|
+
title: ( localize2WithPath(_moduleId, 5, "Join With Previous Cell")),
|
|
188
|
+
keybinding: {
|
|
189
|
+
when: NOTEBOOK_EDITOR_FOCUSED,
|
|
190
|
+
primary: KeyMod.WinCtrl | KeyMod.Alt | KeyMod.Shift | KeyCode.KeyJ,
|
|
191
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
192
|
+
},
|
|
193
|
+
menu: {
|
|
194
|
+
id: MenuId.NotebookCellTitle,
|
|
195
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE))),
|
|
196
|
+
group: CellOverflowToolbarGroups.Edit,
|
|
197
|
+
order: 10
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async runWithContext(accessor, context) {
|
|
202
|
+
const bulkEditService = accessor.get(IBulkEditService);
|
|
203
|
+
return joinCellsWithSurrounds(bulkEditService, context, 'above');
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
registerAction2(class extends NotebookCellAction {
|
|
207
|
+
constructor() {
|
|
208
|
+
super({
|
|
209
|
+
id: JOIN_CELL_BELOW_COMMAND_ID,
|
|
210
|
+
title: ( localize2WithPath(_moduleId, 6, "Join With Next Cell")),
|
|
211
|
+
keybinding: {
|
|
212
|
+
when: NOTEBOOK_EDITOR_FOCUSED,
|
|
213
|
+
primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KeyJ,
|
|
214
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
215
|
+
},
|
|
216
|
+
menu: {
|
|
217
|
+
id: MenuId.NotebookCellTitle,
|
|
218
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE))),
|
|
219
|
+
group: CellOverflowToolbarGroups.Edit,
|
|
220
|
+
order: 11
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async runWithContext(accessor, context) {
|
|
225
|
+
const bulkEditService = accessor.get(IBulkEditService);
|
|
226
|
+
return joinCellsWithSurrounds(bulkEditService, context, 'below');
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
registerAction2(class extends NotebookCellAction {
|
|
230
|
+
constructor() {
|
|
231
|
+
super({
|
|
232
|
+
id: JOIN_SELECTED_CELLS_COMMAND_ID,
|
|
233
|
+
title: ( localize2WithPath(_moduleId, 7, "Join Selected Cells")),
|
|
234
|
+
menu: {
|
|
235
|
+
id: MenuId.NotebookCellTitle,
|
|
236
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE))),
|
|
237
|
+
group: CellOverflowToolbarGroups.Edit,
|
|
238
|
+
order: 12
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
async runWithContext(accessor, context) {
|
|
243
|
+
const bulkEditService = accessor.get(IBulkEditService);
|
|
244
|
+
const notificationService = accessor.get(INotificationService);
|
|
245
|
+
return joinSelectedCells(bulkEditService, notificationService, context);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
const CHANGE_CELL_TO_CODE_COMMAND_ID = 'notebook.cell.changeToCode';
|
|
249
|
+
const CHANGE_CELL_TO_MARKDOWN_COMMAND_ID = 'notebook.cell.changeToMarkdown';
|
|
250
|
+
registerAction2(class ChangeCellToCodeAction extends NotebookMultiCellAction {
|
|
251
|
+
constructor() {
|
|
252
|
+
super({
|
|
253
|
+
id: CHANGE_CELL_TO_CODE_COMMAND_ID,
|
|
254
|
+
title: ( localize2WithPath(_moduleId, 8, "Change Cell to Code")),
|
|
255
|
+
keybinding: {
|
|
256
|
+
when: ( (ContextKeyExpr.and(
|
|
257
|
+
NOTEBOOK_EDITOR_FOCUSED,
|
|
258
|
+
ContextKeyExpr.not(InputFocusedContextKey),
|
|
259
|
+
(NOTEBOOK_OUTPUT_FOCUSED.toNegated())
|
|
260
|
+
))),
|
|
261
|
+
primary: KeyCode.KeyY,
|
|
262
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
263
|
+
},
|
|
264
|
+
precondition: ( (ContextKeyExpr.and(
|
|
265
|
+
NOTEBOOK_IS_ACTIVE_EDITOR,
|
|
266
|
+
(NOTEBOOK_CELL_TYPE.isEqualTo('markup'))
|
|
267
|
+
))),
|
|
268
|
+
menu: {
|
|
269
|
+
id: MenuId.NotebookCellTitle,
|
|
270
|
+
when: ( (ContextKeyExpr.and(
|
|
271
|
+
NOTEBOOK_EDITOR_FOCUSED,
|
|
272
|
+
NOTEBOOK_EDITOR_EDITABLE,
|
|
273
|
+
NOTEBOOK_CELL_EDITABLE,
|
|
274
|
+
(NOTEBOOK_CELL_TYPE.isEqualTo('markup'))
|
|
275
|
+
))),
|
|
276
|
+
group: CellOverflowToolbarGroups.Edit,
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
async runWithContext(accessor, context) {
|
|
281
|
+
await changeCellToKind(CellKind.Code, context);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
registerAction2(class ChangeCellToMarkdownAction extends NotebookMultiCellAction {
|
|
285
|
+
constructor() {
|
|
286
|
+
super({
|
|
287
|
+
id: CHANGE_CELL_TO_MARKDOWN_COMMAND_ID,
|
|
288
|
+
title: ( localize2WithPath(_moduleId, 9, "Change Cell to Markdown")),
|
|
289
|
+
keybinding: {
|
|
290
|
+
when: ( (ContextKeyExpr.and(
|
|
291
|
+
NOTEBOOK_EDITOR_FOCUSED,
|
|
292
|
+
ContextKeyExpr.not(InputFocusedContextKey),
|
|
293
|
+
(NOTEBOOK_OUTPUT_FOCUSED.toNegated())
|
|
294
|
+
))),
|
|
295
|
+
primary: KeyCode.KeyM,
|
|
296
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
297
|
+
},
|
|
298
|
+
precondition: ( (ContextKeyExpr.and(
|
|
299
|
+
NOTEBOOK_IS_ACTIVE_EDITOR,
|
|
300
|
+
(NOTEBOOK_CELL_TYPE.isEqualTo('code'))
|
|
301
|
+
))),
|
|
302
|
+
menu: {
|
|
303
|
+
id: MenuId.NotebookCellTitle,
|
|
304
|
+
when: ( (ContextKeyExpr.and(
|
|
305
|
+
NOTEBOOK_EDITOR_FOCUSED,
|
|
306
|
+
NOTEBOOK_EDITOR_EDITABLE,
|
|
307
|
+
NOTEBOOK_CELL_EDITABLE,
|
|
308
|
+
(NOTEBOOK_CELL_TYPE.isEqualTo('code'))
|
|
309
|
+
))),
|
|
310
|
+
group: CellOverflowToolbarGroups.Edit,
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
async runWithContext(accessor, context) {
|
|
315
|
+
await changeCellToKind(CellKind.Markup, context, 'markdown', Mimes.markdown);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
const COLLAPSE_CELL_INPUT_COMMAND_ID = 'notebook.cell.collapseCellInput';
|
|
319
|
+
const COLLAPSE_CELL_OUTPUT_COMMAND_ID = 'notebook.cell.collapseCellOutput';
|
|
320
|
+
const COLLAPSE_ALL_CELL_INPUTS_COMMAND_ID = 'notebook.cell.collapseAllCellInputs';
|
|
321
|
+
const EXPAND_ALL_CELL_INPUTS_COMMAND_ID = 'notebook.cell.expandAllCellInputs';
|
|
322
|
+
const COLLAPSE_ALL_CELL_OUTPUTS_COMMAND_ID = 'notebook.cell.collapseAllCellOutputs';
|
|
323
|
+
const EXPAND_ALL_CELL_OUTPUTS_COMMAND_ID = 'notebook.cell.expandAllCellOutputs';
|
|
324
|
+
const TOGGLE_CELL_OUTPUTS_COMMAND_ID = 'notebook.cell.toggleOutputs';
|
|
325
|
+
const TOGGLE_CELL_OUTPUT_SCROLLING = 'notebook.cell.toggleOutputScrolling';
|
|
326
|
+
registerAction2(class CollapseCellInputAction extends NotebookMultiCellAction {
|
|
327
|
+
constructor() {
|
|
328
|
+
super({
|
|
329
|
+
id: COLLAPSE_CELL_INPUT_COMMAND_ID,
|
|
330
|
+
title: ( localize2WithPath(_moduleId, 10, "Collapse Cell Input")),
|
|
331
|
+
keybinding: {
|
|
332
|
+
when: ( (ContextKeyExpr.and(
|
|
333
|
+
NOTEBOOK_CELL_LIST_FOCUSED,
|
|
334
|
+
(NOTEBOOK_CELL_INPUT_COLLAPSED.toNegated()),
|
|
335
|
+
(InputFocusedContext.toNegated())
|
|
336
|
+
))),
|
|
337
|
+
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyC),
|
|
338
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
parseArgs(accessor, ...args) {
|
|
343
|
+
return parseMultiCellExecutionArgs(accessor, ...args);
|
|
344
|
+
}
|
|
345
|
+
async runWithContext(accessor, context) {
|
|
346
|
+
if (context.ui) {
|
|
347
|
+
context.cell.isInputCollapsed = true;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
context.selectedCells.forEach(cell => cell.isInputCollapsed = true);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
registerAction2(class ExpandCellInputAction extends NotebookMultiCellAction {
|
|
355
|
+
constructor() {
|
|
356
|
+
super({
|
|
357
|
+
id: EXPAND_CELL_INPUT_COMMAND_ID,
|
|
358
|
+
title: ( localize2WithPath(_moduleId, 11, "Expand Cell Input")),
|
|
359
|
+
keybinding: {
|
|
360
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_INPUT_COLLAPSED))),
|
|
361
|
+
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyC),
|
|
362
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
parseArgs(accessor, ...args) {
|
|
367
|
+
return parseMultiCellExecutionArgs(accessor, ...args);
|
|
368
|
+
}
|
|
369
|
+
async runWithContext(accessor, context) {
|
|
370
|
+
if (context.ui) {
|
|
371
|
+
context.cell.isInputCollapsed = false;
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
context.selectedCells.forEach(cell => cell.isInputCollapsed = false);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
registerAction2(class CollapseCellOutputAction extends NotebookMultiCellAction {
|
|
379
|
+
constructor() {
|
|
380
|
+
super({
|
|
381
|
+
id: COLLAPSE_CELL_OUTPUT_COMMAND_ID,
|
|
382
|
+
title: ( localize2WithPath(_moduleId, 12, "Collapse Cell Output")),
|
|
383
|
+
keybinding: {
|
|
384
|
+
when: ( (ContextKeyExpr.and(
|
|
385
|
+
NOTEBOOK_CELL_LIST_FOCUSED,
|
|
386
|
+
(NOTEBOOK_CELL_OUTPUT_COLLAPSED.toNegated()),
|
|
387
|
+
(InputFocusedContext.toNegated()),
|
|
388
|
+
NOTEBOOK_CELL_HAS_OUTPUTS
|
|
389
|
+
))),
|
|
390
|
+
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.KeyT),
|
|
391
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
async runWithContext(accessor, context) {
|
|
396
|
+
if (context.ui) {
|
|
397
|
+
context.cell.isOutputCollapsed = true;
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
context.selectedCells.forEach(cell => cell.isOutputCollapsed = true);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
registerAction2(class ExpandCellOuputAction extends NotebookMultiCellAction {
|
|
405
|
+
constructor() {
|
|
406
|
+
super({
|
|
407
|
+
id: EXPAND_CELL_OUTPUT_COMMAND_ID,
|
|
408
|
+
title: ( localize2WithPath(_moduleId, 13, "Expand Cell Output")),
|
|
409
|
+
keybinding: {
|
|
410
|
+
when: ( (ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_OUTPUT_COLLAPSED))),
|
|
411
|
+
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.KeyT),
|
|
412
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
async runWithContext(accessor, context) {
|
|
417
|
+
if (context.ui) {
|
|
418
|
+
context.cell.isOutputCollapsed = false;
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
context.selectedCells.forEach(cell => cell.isOutputCollapsed = false);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
registerAction2(class extends NotebookMultiCellAction {
|
|
426
|
+
constructor() {
|
|
427
|
+
super({
|
|
428
|
+
id: TOGGLE_CELL_OUTPUTS_COMMAND_ID,
|
|
429
|
+
precondition: NOTEBOOK_CELL_LIST_FOCUSED,
|
|
430
|
+
title: ( localize2WithPath(_moduleId, 14, "Toggle Outputs")),
|
|
431
|
+
metadata: {
|
|
432
|
+
description: ( localizeWithPath(_moduleId, 14, "Toggle Outputs")),
|
|
433
|
+
args: cellExecutionArgs
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
parseArgs(accessor, ...args) {
|
|
438
|
+
return parseMultiCellExecutionArgs(accessor, ...args);
|
|
439
|
+
}
|
|
440
|
+
async runWithContext(accessor, context) {
|
|
441
|
+
let cells = [];
|
|
442
|
+
if (context.ui) {
|
|
443
|
+
cells = [context.cell];
|
|
444
|
+
}
|
|
445
|
+
else if (context.selectedCells) {
|
|
446
|
+
cells = context.selectedCells;
|
|
447
|
+
}
|
|
448
|
+
for (const cell of cells) {
|
|
449
|
+
cell.isOutputCollapsed = !cell.isOutputCollapsed;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
registerAction2(class CollapseAllCellInputsAction extends NotebookMultiCellAction {
|
|
454
|
+
constructor() {
|
|
455
|
+
super({
|
|
456
|
+
id: COLLAPSE_ALL_CELL_INPUTS_COMMAND_ID,
|
|
457
|
+
title: ( localize2WithPath(_moduleId, 15, "Collapse All Cell Inputs")),
|
|
458
|
+
f1: true,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
async runWithContext(accessor, context) {
|
|
462
|
+
forEachCell(context.notebookEditor, cell => cell.isInputCollapsed = true);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
registerAction2(class ExpandAllCellInputsAction extends NotebookMultiCellAction {
|
|
466
|
+
constructor() {
|
|
467
|
+
super({
|
|
468
|
+
id: EXPAND_ALL_CELL_INPUTS_COMMAND_ID,
|
|
469
|
+
title: ( localize2WithPath(_moduleId, 16, "Expand All Cell Inputs")),
|
|
470
|
+
f1: true
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
async runWithContext(accessor, context) {
|
|
474
|
+
forEachCell(context.notebookEditor, cell => cell.isInputCollapsed = false);
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
registerAction2(class CollapseAllCellOutputsAction extends NotebookMultiCellAction {
|
|
478
|
+
constructor() {
|
|
479
|
+
super({
|
|
480
|
+
id: COLLAPSE_ALL_CELL_OUTPUTS_COMMAND_ID,
|
|
481
|
+
title: ( localize2WithPath(_moduleId, 17, "Collapse All Cell Outputs")),
|
|
482
|
+
f1: true,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
async runWithContext(accessor, context) {
|
|
486
|
+
forEachCell(context.notebookEditor, cell => cell.isOutputCollapsed = true);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
registerAction2(class ExpandAllCellOutputsAction extends NotebookMultiCellAction {
|
|
490
|
+
constructor() {
|
|
491
|
+
super({
|
|
492
|
+
id: EXPAND_ALL_CELL_OUTPUTS_COMMAND_ID,
|
|
493
|
+
title: ( localize2WithPath(_moduleId, 18, "Expand All Cell Outputs")),
|
|
494
|
+
f1: true
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
async runWithContext(accessor, context) {
|
|
498
|
+
forEachCell(context.notebookEditor, cell => cell.isOutputCollapsed = false);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
registerAction2(class ToggleCellOutputScrolling extends NotebookMultiCellAction {
|
|
502
|
+
constructor() {
|
|
503
|
+
super({
|
|
504
|
+
id: TOGGLE_CELL_OUTPUT_SCROLLING,
|
|
505
|
+
title: ( localize2WithPath(_moduleId, 19, "Toggle Scroll Cell Output")),
|
|
506
|
+
keybinding: {
|
|
507
|
+
when: ( (ContextKeyExpr.and(
|
|
508
|
+
NOTEBOOK_CELL_LIST_FOCUSED,
|
|
509
|
+
(InputFocusedContext.toNegated()),
|
|
510
|
+
NOTEBOOK_CELL_HAS_OUTPUTS
|
|
511
|
+
))),
|
|
512
|
+
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.KeyY),
|
|
513
|
+
weight: KeybindingWeight.WorkbenchContrib
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
toggleOutputScrolling(viewModel, globalScrollSetting, collapsed) {
|
|
518
|
+
const cellMetadata = viewModel.model.metadata;
|
|
519
|
+
if (cellMetadata) {
|
|
520
|
+
const currentlyEnabled = cellMetadata['scrollable'] !== undefined ? cellMetadata['scrollable'] : globalScrollSetting;
|
|
521
|
+
const shouldEnableScrolling = collapsed || !currentlyEnabled;
|
|
522
|
+
cellMetadata['scrollable'] = shouldEnableScrolling;
|
|
523
|
+
viewModel.resetRenderer();
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
async runWithContext(accessor, context) {
|
|
527
|
+
const globalScrolling = accessor.get(IConfigurationService).getValue(NotebookSetting.outputScrolling);
|
|
528
|
+
if (context.ui) {
|
|
529
|
+
context.cell.outputsViewModels.forEach((viewModel) => {
|
|
530
|
+
this.toggleOutputScrolling(viewModel, globalScrolling, context.cell.isOutputCollapsed);
|
|
531
|
+
});
|
|
532
|
+
context.cell.isOutputCollapsed = false;
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
context.selectedCells.forEach(cell => {
|
|
536
|
+
cell.outputsViewModels.forEach((viewModel) => {
|
|
537
|
+
this.toggleOutputScrolling(viewModel, globalScrolling, cell.isOutputCollapsed);
|
|
538
|
+
});
|
|
539
|
+
cell.isOutputCollapsed = false;
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
function forEachCell(editor, callback) {
|
|
545
|
+
for (let i = 0; i < editor.getLength(); i++) {
|
|
546
|
+
const cell = editor.cellAt(i);
|
|
547
|
+
callback(cell, i);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
+
import { IMarkerService } from 'vscode/vscode/vs/platform/markers/common/markers.service';
|
|
4
|
+
import { NotebookExecutionType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
|
|
5
|
+
import { INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService.service';
|
|
6
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
7
|
+
import { NotebookSetting, CellKind } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
8
|
+
import { registerNotebookContribution } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
|
9
|
+
import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
|
|
10
|
+
import { CodeCellViewModel } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
|
|
11
|
+
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
12
|
+
import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
13
|
+
|
|
14
|
+
var CellDiagnostics_1;
|
|
15
|
+
let CellDiagnostics = class CellDiagnostics extends Disposable {
|
|
16
|
+
static { CellDiagnostics_1 = this; }
|
|
17
|
+
static { this.ID = 'workbench.notebook.cellDiagnostics'; }
|
|
18
|
+
constructor(notebookEditor, notebookExecutionStateService, markerService, chatAgentService, configurationService) {
|
|
19
|
+
super();
|
|
20
|
+
this.notebookEditor = notebookEditor;
|
|
21
|
+
this.notebookExecutionStateService = notebookExecutionStateService;
|
|
22
|
+
this.markerService = markerService;
|
|
23
|
+
this.chatAgentService = chatAgentService;
|
|
24
|
+
this.configurationService = configurationService;
|
|
25
|
+
this.enabled = false;
|
|
26
|
+
this.listening = false;
|
|
27
|
+
this.diagnosticsByHandle = ( new Map());
|
|
28
|
+
this.updateEnabled();
|
|
29
|
+
this._register(chatAgentService.onDidChangeAgents(() => this.updateEnabled()));
|
|
30
|
+
this._register(configurationService.onDidChangeConfiguration((e) => {
|
|
31
|
+
if (e.affectsConfiguration(NotebookSetting.cellFailureDiagnostics)) {
|
|
32
|
+
this.updateEnabled();
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
updateEnabled() {
|
|
37
|
+
const settingEnabled = this.configurationService.getValue(NotebookSetting.cellFailureDiagnostics);
|
|
38
|
+
if (this.enabled && (!settingEnabled || Iterable.isEmpty(this.chatAgentService.getAgents()))) {
|
|
39
|
+
this.enabled = false;
|
|
40
|
+
this.clearAll();
|
|
41
|
+
}
|
|
42
|
+
else if (!this.enabled && settingEnabled && !Iterable.isEmpty(this.chatAgentService.getAgents())) {
|
|
43
|
+
this.enabled = true;
|
|
44
|
+
if (!this.listening) {
|
|
45
|
+
this.listening = true;
|
|
46
|
+
this._register(Event.accumulate(this.notebookExecutionStateService.onDidChangeExecution, 200)((e) => this.handleChangeExecutionState(e)));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
handleChangeExecutionState(changes) {
|
|
51
|
+
if (!this.enabled) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const handled = ( new Set());
|
|
55
|
+
for (const e of changes.reverse()) {
|
|
56
|
+
const notebookUri = this.notebookEditor.textModel?.uri;
|
|
57
|
+
if (e.type === NotebookExecutionType.cell && notebookUri && e.affectsNotebook(notebookUri) && !( handled.has(e.cellHandle))) {
|
|
58
|
+
handled.add(e.cellHandle);
|
|
59
|
+
if (!!e.changed) {
|
|
60
|
+
this.clear(e.cellHandle);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.setDiagnostics(e.cellHandle);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
clearAll() {
|
|
69
|
+
for (const handle of ( this.diagnosticsByHandle.keys())) {
|
|
70
|
+
this.clear(handle);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
clear(cellHandle) {
|
|
74
|
+
const diagnostic = this.diagnosticsByHandle.get(cellHandle);
|
|
75
|
+
if (diagnostic) {
|
|
76
|
+
for (const disposable of diagnostic.disposables) {
|
|
77
|
+
disposable.dispose();
|
|
78
|
+
}
|
|
79
|
+
this.diagnosticsByHandle.delete(cellHandle);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
setDiagnostics(cellHandle) {
|
|
83
|
+
if (( this.diagnosticsByHandle.has(cellHandle))) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const cell = this.notebookEditor.getCellByHandle(cellHandle);
|
|
87
|
+
if (!cell || cell.cellKind !== CellKind.Code) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const metadata = cell.model.internalMetadata;
|
|
91
|
+
if (cell instanceof CodeCellViewModel && !metadata.lastRunSuccess && metadata?.error?.location) {
|
|
92
|
+
const disposables = [];
|
|
93
|
+
const marker = this.createMarkerData(metadata.error.message, metadata.error.location);
|
|
94
|
+
this.markerService.changeOne(CellDiagnostics_1.ID, cell.uri, [marker]);
|
|
95
|
+
disposables.push(toDisposable(() => this.markerService.changeOne(CellDiagnostics_1.ID, cell.uri, [])));
|
|
96
|
+
cell.excecutionError.set(metadata.error, undefined);
|
|
97
|
+
disposables.push(toDisposable(() => cell.excecutionError.set(undefined, undefined)));
|
|
98
|
+
disposables.push(cell.model.onDidChangeOutputs(() => {
|
|
99
|
+
if (cell.model.outputs.length === 0) {
|
|
100
|
+
this.clear(cellHandle);
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
103
|
+
disposables.push(cell.model.onDidChangeContent(() => {
|
|
104
|
+
this.clear(cellHandle);
|
|
105
|
+
}));
|
|
106
|
+
this.diagnosticsByHandle.set(cellHandle, { cellUri: cell.uri, error: metadata.error, disposables });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
createMarkerData(message, location) {
|
|
110
|
+
return {
|
|
111
|
+
severity: 8,
|
|
112
|
+
message: message,
|
|
113
|
+
startLineNumber: location.startLineNumber + 1,
|
|
114
|
+
startColumn: location.startColumn + 1,
|
|
115
|
+
endLineNumber: location.endLineNumber + 1,
|
|
116
|
+
endColumn: location.endColumn + 1,
|
|
117
|
+
source: 'Cell Execution Error'
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
dispose() {
|
|
121
|
+
super.dispose();
|
|
122
|
+
this.clearAll();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
CellDiagnostics = CellDiagnostics_1 = ( __decorate([
|
|
126
|
+
( __param(1, INotebookExecutionStateService)),
|
|
127
|
+
( __param(2, IMarkerService)),
|
|
128
|
+
( __param(3, IChatAgentService)),
|
|
129
|
+
( __param(4, IConfigurationService))
|
|
130
|
+
], CellDiagnostics));
|
|
131
|
+
registerNotebookContribution(CellDiagnostics.ID, CellDiagnostics);
|
|
132
|
+
|
|
133
|
+
export { CellDiagnostics };
|