@codingame/monaco-vscode-notebook-service-override 25.1.2 → 26.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/index.js +2 -2
- package/package.json +3 -3
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +112 -94
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +95 -96
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +28 -19
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +15 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +22 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +25 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +37 -44
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +211 -115
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +16 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +5 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +57 -49
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +24 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +78 -76
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +14 -15
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +43 -28
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +65 -34
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +19 -16
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +6 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +15 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +28 -16
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +211 -170
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookSelectionHighlight.js +11 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +158 -156
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.js +109 -105
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +28 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +26 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +23 -16
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +72 -40
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +233 -186
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +22 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +239 -151
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +85 -86
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +25 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +13 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +8 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +218 -196
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +258 -255
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +106 -98
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +63 -49
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +55 -64
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.js +21 -25
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +149 -129
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.d.ts +57 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.js +286 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditorInput.d.ts +22 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditorInput.js +82 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +452 -363
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +44 -61
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +9 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +203 -207
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditor.js +148 -104
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditorInput.js +19 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/replEditorAccessibleView.js +9 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl.js +9 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +34 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +29 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +70 -52
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +31 -19
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +78 -41
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +37 -27
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +9 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +8 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +214 -119
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +38 -36
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineDataSource.js +24 -25
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineDataSourceFactory.js +2 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +26 -15
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +35 -15
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +468 -258
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.d.ts +33 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +113 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +74 -58
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +7 -10
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookCellMatching.js +72 -16
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookWebWorker.js +70 -51
- package/vscode/src/vs/workbench/contrib/replNotebook/browser/repl.contribution.js +195 -149
- package/vscode/src/vs/workbench/contrib/replNotebook/browser/replEditorAccessibilityHelp.js +60 -81
- package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +7 -12
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +104 -66
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +115 -77
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +42 -26
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +19 -12
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.d.ts +0 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +0 -198
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.d.ts +0 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +0 -333
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.d.ts +0 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +0 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -261
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
4
|
-
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
5
|
-
import { codiconsLibrary } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codiconsLibrary';
|
|
6
|
-
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
|
-
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
8
|
-
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
9
|
-
import { CompletionItemKind } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
|
|
10
|
-
import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
|
|
11
|
-
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
12
|
-
import { Action2, registerAction2, MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
13
|
-
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
14
|
-
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
15
|
-
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
16
|
-
import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
17
|
-
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
18
|
-
import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
19
|
-
import { IChatContextPickService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/attachments/chatContextPickService.service';
|
|
20
|
-
import { ChatDynamicVariableModel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/attachments/chatDynamicVariables';
|
|
21
|
-
import { computeCompletionRanges } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions';
|
|
22
|
-
import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/participants/chatAgents.service';
|
|
23
|
-
import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/actions/chatContextKeys';
|
|
24
|
-
import { chatVariableLeader } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/requestParser/chatParserTypes';
|
|
25
|
-
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
26
|
-
import { NOTEBOOK_CELL_OUTPUT_MIME_TYPE_LIST_FOR_CHAT, NOTEBOOK_CELL_HAS_OUTPUTS, NOTEBOOK_CELL_OUTPUT_MIMETYPE } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
|
|
27
|
-
import { INotebookKernelService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookKernelService.service';
|
|
28
|
-
import { NOTEBOOK_CELL_OUTPUT_MIME_TYPE_LIST_FOR_CHAT_CONST, createNotebookOutputVariableEntry } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/notebook/browser/contrib/chat/notebookChatUtils';
|
|
29
|
-
import { getNotebookEditorFromEditorPane } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
30
|
-
import { copyIcon } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
|
|
31
|
-
import { getOutputViewModelFromId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/controller/cellOutputActions';
|
|
32
|
-
import { NOTEBOOK_ACTIONS_CATEGORY } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
|
|
33
|
-
import './cellChatActions.js';
|
|
34
|
-
import { CTX_NOTEBOOK_CHAT_HAS_AGENT } from './notebookChatContext.js';
|
|
35
|
-
|
|
36
|
-
const NotebookKernelVariableKey = 'kernelVariable';
|
|
37
|
-
let NotebookChatContribution = class NotebookChatContribution extends Disposable {
|
|
38
|
-
static { this.ID = 'workbench.contrib.notebookChatContribution'; }
|
|
39
|
-
constructor(contextKeyService, chatAgentService, editorService, chatWidgetService, notebookKernelService, languageFeaturesService, chatContextPickService) {
|
|
40
|
-
super();
|
|
41
|
-
this.editorService = editorService;
|
|
42
|
-
this.chatWidgetService = chatWidgetService;
|
|
43
|
-
this.notebookKernelService = notebookKernelService;
|
|
44
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
45
|
-
this._register(chatContextPickService.registerChatContextItem(( new KernelVariableContextPicker(this.editorService, this.notebookKernelService))));
|
|
46
|
-
this._ctxHasProvider = CTX_NOTEBOOK_CHAT_HAS_AGENT.bindTo(contextKeyService);
|
|
47
|
-
const updateNotebookAgentStatus = () => {
|
|
48
|
-
const hasNotebookAgent = Boolean(chatAgentService.getDefaultAgent(ChatAgentLocation.Notebook));
|
|
49
|
-
this._ctxHasProvider.set(hasNotebookAgent);
|
|
50
|
-
};
|
|
51
|
-
updateNotebookAgentStatus();
|
|
52
|
-
this._register(chatAgentService.onDidChangeAgents(updateNotebookAgentStatus));
|
|
53
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: Schemas.vscodeChatInput, hasAccessToAllModels: true }, {
|
|
54
|
-
_debugDisplayName: 'chatKernelDynamicCompletions',
|
|
55
|
-
triggerCharacters: [chatVariableLeader],
|
|
56
|
-
provideCompletionItems: async (model, position, _context, token) => {
|
|
57
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
58
|
-
if (!widget || !widget.supportsFileReferences) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
if (widget.location !== ChatAgentLocation.Notebook) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
const variableNameDef = ( new RegExp(`${chatVariableLeader}\\w*`, 'g'));
|
|
65
|
-
const range = computeCompletionRanges(model, position, variableNameDef, true);
|
|
66
|
-
if (!range) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
const result = { suggestions: [] };
|
|
70
|
-
const afterRange = ( new Range(
|
|
71
|
-
position.lineNumber,
|
|
72
|
-
range.replace.startColumn,
|
|
73
|
-
position.lineNumber,
|
|
74
|
-
range.replace.startColumn + `${chatVariableLeader}${NotebookKernelVariableKey}:`.length
|
|
75
|
-
));
|
|
76
|
-
result.suggestions.push({
|
|
77
|
-
label: `${chatVariableLeader}${NotebookKernelVariableKey}`,
|
|
78
|
-
insertText: `${chatVariableLeader}${NotebookKernelVariableKey}:`,
|
|
79
|
-
detail: ( localize(9363, "Pick a variable from the kernel")),
|
|
80
|
-
range,
|
|
81
|
-
kind: CompletionItemKind.Text,
|
|
82
|
-
command: { id: SelectAndInsertKernelVariableAction.ID, title: SelectAndInsertKernelVariableAction.ID, arguments: [{ widget, range: afterRange }] },
|
|
83
|
-
sortText: 'z'
|
|
84
|
-
});
|
|
85
|
-
await this.addKernelVariableCompletion(widget, result, range, token);
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
}));
|
|
89
|
-
NOTEBOOK_CELL_OUTPUT_MIME_TYPE_LIST_FOR_CHAT.bindTo(contextKeyService).set(NOTEBOOK_CELL_OUTPUT_MIME_TYPE_LIST_FOR_CHAT_CONST);
|
|
90
|
-
}
|
|
91
|
-
async addKernelVariableCompletion(widget, result, info, token) {
|
|
92
|
-
let pattern;
|
|
93
|
-
if (info.varWord?.word && info.varWord.word.startsWith(chatVariableLeader)) {
|
|
94
|
-
pattern = info.varWord.word.toLowerCase().slice(1);
|
|
95
|
-
}
|
|
96
|
-
const notebook = getNotebookEditorFromEditorPane(this.editorService.activeEditorPane)?.getViewModel()?.notebookDocument;
|
|
97
|
-
if (!notebook) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const selectedKernel = this.notebookKernelService.getMatchingKernel(notebook).selected;
|
|
101
|
-
const hasVariableProvider = selectedKernel?.hasVariableProvider;
|
|
102
|
-
if (!hasVariableProvider) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const variables = selectedKernel.provideVariables(notebook.uri, undefined, 'named', 0, CancellationToken.None);
|
|
106
|
-
for await (const variable of variables) {
|
|
107
|
-
if (pattern && !variable.name.toLowerCase().includes(pattern)) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
result.suggestions.push({
|
|
111
|
-
label: { label: variable.name, description: variable.type },
|
|
112
|
-
insertText: `${chatVariableLeader}${NotebookKernelVariableKey}:${variable.name} `,
|
|
113
|
-
filterText: `${chatVariableLeader}${variable.name}`,
|
|
114
|
-
range: info,
|
|
115
|
-
kind: CompletionItemKind.Variable,
|
|
116
|
-
sortText: 'z',
|
|
117
|
-
command: { id: SelectAndInsertKernelVariableAction.ID, title: SelectAndInsertKernelVariableAction.ID, arguments: [{ widget, range: info.insert, variable: variable.name }] },
|
|
118
|
-
detail: variable.type,
|
|
119
|
-
documentation: variable.value,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
NotebookChatContribution = ( __decorate([
|
|
125
|
-
( __param(0, IContextKeyService)),
|
|
126
|
-
( __param(1, IChatAgentService)),
|
|
127
|
-
( __param(2, IEditorService)),
|
|
128
|
-
( __param(3, IChatWidgetService)),
|
|
129
|
-
( __param(4, INotebookKernelService)),
|
|
130
|
-
( __param(5, ILanguageFeaturesService)),
|
|
131
|
-
( __param(6, IChatContextPickService))
|
|
132
|
-
], NotebookChatContribution));
|
|
133
|
-
class SelectAndInsertKernelVariableAction extends Action2 {
|
|
134
|
-
constructor() {
|
|
135
|
-
super({
|
|
136
|
-
id: SelectAndInsertKernelVariableAction.ID,
|
|
137
|
-
title: ''
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
static { this.ID = 'notebook.chat.selectAndInsertKernelVariable'; }
|
|
141
|
-
async run(accessor, ...args) {
|
|
142
|
-
const editorService = accessor.get(IEditorService);
|
|
143
|
-
const notebookKernelService = accessor.get(INotebookKernelService);
|
|
144
|
-
const quickInputService = accessor.get(IQuickInputService);
|
|
145
|
-
const notebook = getNotebookEditorFromEditorPane(editorService.activeEditorPane)?.getViewModel()?.notebookDocument;
|
|
146
|
-
if (!notebook) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const context = args[0];
|
|
150
|
-
if (!context || !('widget' in context) || !('range' in context)) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const widget = context.widget;
|
|
154
|
-
const range = context.range;
|
|
155
|
-
const variable = context.variable;
|
|
156
|
-
if (variable !== undefined) {
|
|
157
|
-
this.addVariableReference(widget, variable, range, false);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const selectedKernel = notebookKernelService.getMatchingKernel(notebook).selected;
|
|
161
|
-
const hasVariableProvider = selectedKernel?.hasVariableProvider;
|
|
162
|
-
if (!hasVariableProvider) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const variables = selectedKernel.provideVariables(notebook.uri, undefined, 'named', 0, CancellationToken.None);
|
|
166
|
-
const quickPickItems = [];
|
|
167
|
-
for await (const variable of variables) {
|
|
168
|
-
quickPickItems.push({
|
|
169
|
-
label: variable.name,
|
|
170
|
-
description: variable.value,
|
|
171
|
-
detail: variable.type,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
const placeHolder = quickPickItems.length > 0
|
|
175
|
-
? ( localize(9364, "Select a kernel variable"))
|
|
176
|
-
: ( localize(9365, "No kernel variables found"));
|
|
177
|
-
const pickedVariable = await quickInputService.pick(quickPickItems, { placeHolder });
|
|
178
|
-
if (!pickedVariable) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
this.addVariableReference(widget, pickedVariable.label, range, true);
|
|
182
|
-
}
|
|
183
|
-
addVariableReference(widget, variableName, range, updateText) {
|
|
184
|
-
if (range) {
|
|
185
|
-
const text = `#kernelVariable:${variableName}`;
|
|
186
|
-
if (updateText) {
|
|
187
|
-
const editor = widget.inputEditor;
|
|
188
|
-
const success = editor.executeEdits('chatInsertFile', [{ range, text: text + ' ' }]);
|
|
189
|
-
if (!success) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
widget.getContrib(ChatDynamicVariableModel.ID)?.addReference({
|
|
194
|
-
id: 'vscode.notebook.variable',
|
|
195
|
-
range: { startLineNumber: range.startLineNumber, startColumn: range.startColumn, endLineNumber: range.endLineNumber, endColumn: range.startColumn + text.length },
|
|
196
|
-
data: variableName,
|
|
197
|
-
fullName: variableName,
|
|
198
|
-
icon: codiconsLibrary.variable,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
widget.attachmentModel.addContext({
|
|
203
|
-
id: 'vscode.notebook.variable',
|
|
204
|
-
name: variableName,
|
|
205
|
-
value: variableName,
|
|
206
|
-
icon: codiconsLibrary.variable,
|
|
207
|
-
kind: 'generic'
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
let KernelVariableContextPicker = class KernelVariableContextPicker {
|
|
213
|
-
constructor(editorService, notebookKernelService) {
|
|
214
|
-
this.editorService = editorService;
|
|
215
|
-
this.notebookKernelService = notebookKernelService;
|
|
216
|
-
this.type = 'pickerPick';
|
|
217
|
-
this.label = ( localize(9366, 'Kernel Variable...'));
|
|
218
|
-
this.icon = Codicon.serverEnvironment;
|
|
219
|
-
}
|
|
220
|
-
isEnabled(widget) {
|
|
221
|
-
return widget.location === ChatAgentLocation.Notebook && Boolean(getNotebookEditorFromEditorPane(this.editorService.activeEditorPane)?.getViewModel()?.notebookDocument);
|
|
222
|
-
}
|
|
223
|
-
asPicker() {
|
|
224
|
-
const picks = (async () => {
|
|
225
|
-
const notebook = getNotebookEditorFromEditorPane(this.editorService.activeEditorPane)?.getViewModel()?.notebookDocument;
|
|
226
|
-
if (!notebook) {
|
|
227
|
-
return [];
|
|
228
|
-
}
|
|
229
|
-
const selectedKernel = this.notebookKernelService.getMatchingKernel(notebook).selected;
|
|
230
|
-
const hasVariableProvider = selectedKernel?.hasVariableProvider;
|
|
231
|
-
if (!hasVariableProvider) {
|
|
232
|
-
return [];
|
|
233
|
-
}
|
|
234
|
-
const variables = selectedKernel.provideVariables(notebook.uri, undefined, 'named', 0, CancellationToken.None);
|
|
235
|
-
const result = [];
|
|
236
|
-
for await (const variable of variables) {
|
|
237
|
-
result.push({
|
|
238
|
-
label: variable.name,
|
|
239
|
-
description: variable.value,
|
|
240
|
-
asAttachment: () => {
|
|
241
|
-
return {
|
|
242
|
-
kind: 'generic',
|
|
243
|
-
id: 'vscode.notebook.variable',
|
|
244
|
-
name: variable.name,
|
|
245
|
-
value: variable.value,
|
|
246
|
-
icon: codiconsLibrary.variable,
|
|
247
|
-
};
|
|
248
|
-
},
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
return result;
|
|
252
|
-
})();
|
|
253
|
-
return {
|
|
254
|
-
placeholder: ( localize(9367, 'Select a kernel variable')),
|
|
255
|
-
picks
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
KernelVariableContextPicker = ( __decorate([
|
|
260
|
-
( __param(0, IEditorService)),
|
|
261
|
-
( __param(1, INotebookKernelService))
|
|
262
|
-
], KernelVariableContextPicker));
|
|
263
|
-
registerAction2(class AddCellOutputToChatAction extends Action2 {
|
|
264
|
-
constructor() {
|
|
265
|
-
super({
|
|
266
|
-
id: 'notebook.cellOutput.addToChat',
|
|
267
|
-
title: ( localize(9368, "Add Cell Output to Chat")),
|
|
268
|
-
menu: {
|
|
269
|
-
id: MenuId.NotebookOutputToolbar,
|
|
270
|
-
when: ( ContextKeyExpr.and(
|
|
271
|
-
NOTEBOOK_CELL_HAS_OUTPUTS,
|
|
272
|
-
ContextKeyExpr.in(NOTEBOOK_CELL_OUTPUT_MIMETYPE.key, NOTEBOOK_CELL_OUTPUT_MIME_TYPE_LIST_FOR_CHAT.key)
|
|
273
|
-
)),
|
|
274
|
-
order: 10,
|
|
275
|
-
group: 'notebook_chat_actions'
|
|
276
|
-
},
|
|
277
|
-
category: NOTEBOOK_ACTIONS_CATEGORY,
|
|
278
|
-
icon: copyIcon,
|
|
279
|
-
precondition: ChatContextKeys.enabled
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
getNoteboookEditor(editorService, outputContext) {
|
|
283
|
-
if (outputContext && 'notebookEditor' in outputContext) {
|
|
284
|
-
return outputContext.notebookEditor;
|
|
285
|
-
}
|
|
286
|
-
return getNotebookEditorFromEditorPane(editorService.activeEditorPane);
|
|
287
|
-
}
|
|
288
|
-
async run(accessor, outputContext) {
|
|
289
|
-
const notebookEditor = this.getNoteboookEditor(accessor.get(IEditorService), outputContext);
|
|
290
|
-
if (!notebookEditor) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
let outputViewModel;
|
|
294
|
-
if (outputContext && 'outputId' in outputContext && typeof outputContext.outputId === 'string') {
|
|
295
|
-
outputViewModel = getOutputViewModelFromId(outputContext.outputId, notebookEditor);
|
|
296
|
-
}
|
|
297
|
-
else if (outputContext && 'outputViewModel' in outputContext) {
|
|
298
|
-
outputViewModel = outputContext.outputViewModel;
|
|
299
|
-
}
|
|
300
|
-
if (!outputViewModel) {
|
|
301
|
-
const activeCell = notebookEditor.getActiveCell();
|
|
302
|
-
if (!activeCell) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
if (activeCell.focusedOutputId !== undefined) {
|
|
306
|
-
outputViewModel = activeCell.outputsViewModels.find(output => {
|
|
307
|
-
return output.model.outputId === activeCell.focusedOutputId;
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
outputViewModel = activeCell.outputsViewModels.find(output => output.pickedMimeType?.isTrusted);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
if (!outputViewModel) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
const mimeType = outputViewModel.pickedMimeType?.mimeType;
|
|
318
|
-
const chatWidgetService = accessor.get(IChatWidgetService);
|
|
319
|
-
const widget = await chatWidgetService.revealWidget();
|
|
320
|
-
if (widget && mimeType && NOTEBOOK_CELL_OUTPUT_MIME_TYPE_LIST_FOR_CHAT_CONST.includes(mimeType)) {
|
|
321
|
-
const entry = createNotebookOutputVariableEntry(outputViewModel, mimeType, notebookEditor);
|
|
322
|
-
if (!entry) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
widget.attachmentModel.addContext(entry);
|
|
326
|
-
(await chatWidgetService.revealWidget())?.focusInput();
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
registerAction2(SelectAndInsertKernelVariableAction);
|
|
331
|
-
registerWorkbenchContribution2(NotebookChatContribution.ID, NotebookChatContribution, WorkbenchPhase.BlockRestore);
|
|
332
|
-
|
|
333
|
-
export { SelectAndInsertKernelVariableAction };
|
package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
3
|
-
import { RawContextKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
4
|
-
|
|
5
|
-
const CTX_NOTEBOOK_CHAT_HAS_AGENT = ( new RawContextKey('notebookChatAgentRegistered', false, ( localize(9369, "Whether a chat agent for notebook is registered"))));
|
|
6
|
-
|
|
7
|
-
export { CTX_NOTEBOOK_CHAT_HAS_AGENT };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { IAction2Options } from "@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions";
|
|
2
|
-
import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
-
import { INotebookActionContext, NotebookAction } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions";
|
|
4
|
-
import { CellViewModel } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl";
|
|
5
|
-
import { CellKind } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon";
|
|
6
|
-
export declare function insertNewCell(accessor: ServicesAccessor, context: INotebookActionContext, kind: CellKind, direction: "above" | "below", focusEditor: boolean): CellViewModel | null;
|
|
7
|
-
export declare abstract class InsertCellCommand extends NotebookAction {
|
|
8
|
-
private kind;
|
|
9
|
-
private direction;
|
|
10
|
-
private focusEditor;
|
|
11
|
-
constructor(desc: Readonly<IAction2Options>, kind: CellKind, direction: "above" | "below", focusEditor: boolean);
|
|
12
|
-
runWithContext(accessor: ServicesAccessor, context: INotebookActionContext): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
3
|
-
import { KeyMod, KeyCode } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
|
|
4
|
-
import { ILanguageService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language.service';
|
|
5
|
-
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
6
|
-
import { registerAction2, MenuId, MenuRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
7
|
-
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
8
|
-
import { InputFocusedContext } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkeys';
|
|
9
|
-
import { KeybindingWeight } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybindingsRegistry';
|
|
10
|
-
import { insertCell } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/notebook/browser/controller/cellOperations';
|
|
11
|
-
import { NotebookAction } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
|
|
12
|
-
import { NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_EDITOR_EDITABLE } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
|
|
13
|
-
import { CellKind, NotebookSetting } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
14
|
-
import { INotebookKernelHistoryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookKernelService.service';
|
|
15
|
-
|
|
16
|
-
const INSERT_CODE_CELL_ABOVE_COMMAND_ID = 'notebook.cell.insertCodeCellAbove';
|
|
17
|
-
const INSERT_CODE_CELL_BELOW_COMMAND_ID = 'notebook.cell.insertCodeCellBelow';
|
|
18
|
-
const INSERT_CODE_CELL_ABOVE_AND_FOCUS_CONTAINER_COMMAND_ID = 'notebook.cell.insertCodeCellAboveAndFocusContainer';
|
|
19
|
-
const INSERT_CODE_CELL_BELOW_AND_FOCUS_CONTAINER_COMMAND_ID = 'notebook.cell.insertCodeCellBelowAndFocusContainer';
|
|
20
|
-
const INSERT_CODE_CELL_AT_TOP_COMMAND_ID = 'notebook.cell.insertCodeCellAtTop';
|
|
21
|
-
const INSERT_MARKDOWN_CELL_ABOVE_COMMAND_ID = 'notebook.cell.insertMarkdownCellAbove';
|
|
22
|
-
const INSERT_MARKDOWN_CELL_BELOW_COMMAND_ID = 'notebook.cell.insertMarkdownCellBelow';
|
|
23
|
-
const INSERT_MARKDOWN_CELL_AT_TOP_COMMAND_ID = 'notebook.cell.insertMarkdownCellAtTop';
|
|
24
|
-
function insertNewCell(accessor, context, kind, direction, focusEditor) {
|
|
25
|
-
let newCell = null;
|
|
26
|
-
if (context.ui) {
|
|
27
|
-
context.notebookEditor.focus();
|
|
28
|
-
}
|
|
29
|
-
const languageService = accessor.get(ILanguageService);
|
|
30
|
-
const kernelHistoryService = accessor.get(INotebookKernelHistoryService);
|
|
31
|
-
if (context.cell) {
|
|
32
|
-
const idx = context.notebookEditor.getCellIndex(context.cell);
|
|
33
|
-
newCell = insertCell(languageService, context.notebookEditor, idx, kind, direction, undefined, true, kernelHistoryService);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const focusRange = context.notebookEditor.getFocus();
|
|
37
|
-
const next = Math.max(focusRange.end - 1, 0);
|
|
38
|
-
newCell = insertCell(languageService, context.notebookEditor, next, kind, direction, undefined, true, kernelHistoryService);
|
|
39
|
-
}
|
|
40
|
-
return newCell;
|
|
41
|
-
}
|
|
42
|
-
class InsertCellCommand extends NotebookAction {
|
|
43
|
-
constructor(desc, kind, direction, focusEditor) {
|
|
44
|
-
super(desc);
|
|
45
|
-
this.kind = kind;
|
|
46
|
-
this.direction = direction;
|
|
47
|
-
this.focusEditor = focusEditor;
|
|
48
|
-
}
|
|
49
|
-
async runWithContext(accessor, context) {
|
|
50
|
-
const newCell = await insertNewCell(accessor, context, this.kind, this.direction);
|
|
51
|
-
if (newCell) {
|
|
52
|
-
await context.notebookEditor.focusNotebookCell(newCell, this.focusEditor ? 'editor' : 'container');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
registerAction2(class InsertCodeCellAboveAction extends InsertCellCommand {
|
|
57
|
-
constructor() {
|
|
58
|
-
super({
|
|
59
|
-
id: INSERT_CODE_CELL_ABOVE_COMMAND_ID,
|
|
60
|
-
title: ( localize(9415, "Insert Code Cell Above")),
|
|
61
|
-
keybinding: {
|
|
62
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter,
|
|
63
|
-
when: ( ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, ( InputFocusedContext.toNegated()))),
|
|
64
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
65
|
-
},
|
|
66
|
-
menu: {
|
|
67
|
-
id: MenuId.NotebookCellInsert,
|
|
68
|
-
order: 0
|
|
69
|
-
}
|
|
70
|
-
}, CellKind.Code, 'above', true);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
registerAction2(class InsertCodeCellAboveAndFocusContainerAction extends InsertCellCommand {
|
|
74
|
-
constructor() {
|
|
75
|
-
super({
|
|
76
|
-
id: INSERT_CODE_CELL_ABOVE_AND_FOCUS_CONTAINER_COMMAND_ID,
|
|
77
|
-
title: ( localize(9416, "Insert Code Cell Above and Focus Container"))
|
|
78
|
-
}, CellKind.Code, 'above', false);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
registerAction2(class InsertCodeCellBelowAction extends InsertCellCommand {
|
|
82
|
-
constructor() {
|
|
83
|
-
super({
|
|
84
|
-
id: INSERT_CODE_CELL_BELOW_COMMAND_ID,
|
|
85
|
-
title: ( localize(9417, "Insert Code Cell Below")),
|
|
86
|
-
keybinding: {
|
|
87
|
-
primary: KeyMod.CtrlCmd | KeyCode.Enter,
|
|
88
|
-
when: ( ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, ( InputFocusedContext.toNegated()))),
|
|
89
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
90
|
-
},
|
|
91
|
-
menu: {
|
|
92
|
-
id: MenuId.NotebookCellInsert,
|
|
93
|
-
order: 1
|
|
94
|
-
}
|
|
95
|
-
}, CellKind.Code, 'below', true);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
registerAction2(class InsertCodeCellBelowAndFocusContainerAction extends InsertCellCommand {
|
|
99
|
-
constructor() {
|
|
100
|
-
super({
|
|
101
|
-
id: INSERT_CODE_CELL_BELOW_AND_FOCUS_CONTAINER_COMMAND_ID,
|
|
102
|
-
title: ( localize(9418, "Insert Code Cell Below and Focus Container")),
|
|
103
|
-
}, CellKind.Code, 'below', false);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
registerAction2(class InsertMarkdownCellAboveAction extends InsertCellCommand {
|
|
107
|
-
constructor() {
|
|
108
|
-
super({
|
|
109
|
-
id: INSERT_MARKDOWN_CELL_ABOVE_COMMAND_ID,
|
|
110
|
-
title: ( localize(9419, "Insert Markdown Cell Above")),
|
|
111
|
-
menu: {
|
|
112
|
-
id: MenuId.NotebookCellInsert,
|
|
113
|
-
order: 2
|
|
114
|
-
}
|
|
115
|
-
}, CellKind.Markup, 'above', true);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
registerAction2(class InsertMarkdownCellBelowAction extends InsertCellCommand {
|
|
119
|
-
constructor() {
|
|
120
|
-
super({
|
|
121
|
-
id: INSERT_MARKDOWN_CELL_BELOW_COMMAND_ID,
|
|
122
|
-
title: ( localize(9420, "Insert Markdown Cell Below")),
|
|
123
|
-
menu: {
|
|
124
|
-
id: MenuId.NotebookCellInsert,
|
|
125
|
-
order: 3
|
|
126
|
-
}
|
|
127
|
-
}, CellKind.Markup, 'below', true);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
registerAction2(class InsertCodeCellAtTopAction extends NotebookAction {
|
|
131
|
-
constructor() {
|
|
132
|
-
super({
|
|
133
|
-
id: INSERT_CODE_CELL_AT_TOP_COMMAND_ID,
|
|
134
|
-
title: ( localize(9421, "Add Code Cell At Top")),
|
|
135
|
-
f1: false
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
async run(accessor, context) {
|
|
139
|
-
context = context ?? this.getEditorContextFromArgsOrActive(accessor);
|
|
140
|
-
if (context) {
|
|
141
|
-
this.runWithContext(accessor, context);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async runWithContext(accessor, context) {
|
|
145
|
-
const languageService = accessor.get(ILanguageService);
|
|
146
|
-
const kernelHistoryService = accessor.get(INotebookKernelHistoryService);
|
|
147
|
-
const newCell = insertCell(languageService, context.notebookEditor, 0, CellKind.Code, 'above', undefined, true, kernelHistoryService);
|
|
148
|
-
if (newCell) {
|
|
149
|
-
await context.notebookEditor.focusNotebookCell(newCell, 'editor');
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
registerAction2(class InsertMarkdownCellAtTopAction extends NotebookAction {
|
|
154
|
-
constructor() {
|
|
155
|
-
super({
|
|
156
|
-
id: INSERT_MARKDOWN_CELL_AT_TOP_COMMAND_ID,
|
|
157
|
-
title: ( localize(9422, "Add Markdown Cell At Top")),
|
|
158
|
-
f1: false
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
async run(accessor, context) {
|
|
162
|
-
context = context ?? this.getEditorContextFromArgsOrActive(accessor);
|
|
163
|
-
if (context) {
|
|
164
|
-
this.runWithContext(accessor, context);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
async runWithContext(accessor, context) {
|
|
168
|
-
const languageService = accessor.get(ILanguageService);
|
|
169
|
-
const kernelHistoryService = accessor.get(INotebookKernelHistoryService);
|
|
170
|
-
const newCell = insertCell(languageService, context.notebookEditor, 0, CellKind.Markup, 'above', undefined, true, kernelHistoryService);
|
|
171
|
-
if (newCell) {
|
|
172
|
-
await context.notebookEditor.focusNotebookCell(newCell, 'editor');
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
MenuRegistry.appendMenuItem(MenuId.NotebookCellBetween, {
|
|
177
|
-
command: {
|
|
178
|
-
id: INSERT_CODE_CELL_BELOW_COMMAND_ID,
|
|
179
|
-
title: '$(add) ' + ( localize(9423, "Code")),
|
|
180
|
-
tooltip: ( localize(9424, "Add Code Cell"))
|
|
181
|
-
},
|
|
182
|
-
order: 0,
|
|
183
|
-
group: 'inline',
|
|
184
|
-
when: ( ContextKeyExpr.and(( NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)), ( ContextKeyExpr.notEquals('config.notebook.experimental.insertToolbarAlignment', 'left'))))
|
|
185
|
-
});
|
|
186
|
-
MenuRegistry.appendMenuItem(MenuId.NotebookCellBetween, {
|
|
187
|
-
command: {
|
|
188
|
-
id: INSERT_CODE_CELL_BELOW_COMMAND_ID,
|
|
189
|
-
title: ( localize(9425, "Add Code")),
|
|
190
|
-
icon: Codicon.add,
|
|
191
|
-
tooltip: ( localize(9424, "Add Code Cell"))
|
|
192
|
-
},
|
|
193
|
-
order: 0,
|
|
194
|
-
group: 'inline',
|
|
195
|
-
when: ( ContextKeyExpr.and(( NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)), ( ContextKeyExpr.equals('config.notebook.experimental.insertToolbarAlignment', 'left'))))
|
|
196
|
-
});
|
|
197
|
-
MenuRegistry.appendMenuItem(MenuId.NotebookToolbar, {
|
|
198
|
-
command: {
|
|
199
|
-
id: INSERT_CODE_CELL_BELOW_COMMAND_ID,
|
|
200
|
-
icon: Codicon.add,
|
|
201
|
-
title: ( localize(9426, "Code")),
|
|
202
|
-
tooltip: ( localize(9424, "Add Code Cell"))
|
|
203
|
-
},
|
|
204
|
-
order: -5,
|
|
205
|
-
group: 'navigation/add',
|
|
206
|
-
when: ( ContextKeyExpr.and(( NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)), ( ContextKeyExpr.notEquals('config.notebook.insertToolbarLocation', 'betweenCells')), ( ContextKeyExpr.notEquals('config.notebook.insertToolbarLocation', 'hidden'))))
|
|
207
|
-
});
|
|
208
|
-
MenuRegistry.appendMenuItem(MenuId.NotebookCellListTop, {
|
|
209
|
-
command: {
|
|
210
|
-
id: INSERT_CODE_CELL_AT_TOP_COMMAND_ID,
|
|
211
|
-
title: '$(add) ' + ( localize(9423, "Code")),
|
|
212
|
-
tooltip: ( localize(9424, "Add Code Cell"))
|
|
213
|
-
},
|
|
214
|
-
order: 0,
|
|
215
|
-
group: 'inline',
|
|
216
|
-
when: ( ContextKeyExpr.and(( NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)), ( ContextKeyExpr.notEquals('config.notebook.experimental.insertToolbarAlignment', 'left'))))
|
|
217
|
-
});
|
|
218
|
-
MenuRegistry.appendMenuItem(MenuId.NotebookCellListTop, {
|
|
219
|
-
command: {
|
|
220
|
-
id: INSERT_CODE_CELL_AT_TOP_COMMAND_ID,
|
|
221
|
-
title: ( localize(9427, "Add Code")),
|
|
222
|
-
icon: Codicon.add,
|
|
223
|
-
tooltip: ( localize(9424, "Add Code Cell"))
|
|
224
|
-
},
|
|
225
|
-
order: 0,
|
|
226
|
-
group: 'inline',
|
|
227
|
-
when: ( ContextKeyExpr.and(( NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)), ( ContextKeyExpr.equals('config.notebook.experimental.insertToolbarAlignment', 'left'))))
|
|
228
|
-
});
|
|
229
|
-
MenuRegistry.appendMenuItem(MenuId.NotebookCellBetween, {
|
|
230
|
-
command: {
|
|
231
|
-
id: INSERT_MARKDOWN_CELL_BELOW_COMMAND_ID,
|
|
232
|
-
title: '$(add) ' + ( localize(9428, "Markdown")),
|
|
233
|
-
tooltip: ( localize(9429, "Add Markdown Cell"))
|
|
234
|
-
},
|
|
235
|
-
order: 1,
|
|
236
|
-
group: 'inline',
|
|
237
|
-
when: ( ContextKeyExpr.and(( NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)), ( ContextKeyExpr.notEquals('config.notebook.experimental.insertToolbarAlignment', 'left'))))
|
|
238
|
-
});
|
|
239
|
-
MenuRegistry.appendMenuItem(MenuId.NotebookToolbar, {
|
|
240
|
-
command: {
|
|
241
|
-
id: INSERT_MARKDOWN_CELL_BELOW_COMMAND_ID,
|
|
242
|
-
icon: Codicon.add,
|
|
243
|
-
title: ( localize(9430, "Markdown")),
|
|
244
|
-
tooltip: ( localize(9429, "Add Markdown Cell"))
|
|
245
|
-
},
|
|
246
|
-
order: -5,
|
|
247
|
-
group: 'navigation/add',
|
|
248
|
-
when: ( ContextKeyExpr.and(( NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)), ( ContextKeyExpr.notEquals('config.notebook.insertToolbarLocation', 'betweenCells')), ( ContextKeyExpr.notEquals('config.notebook.insertToolbarLocation', 'hidden')), ( ContextKeyExpr.notEquals(`config.${NotebookSetting.globalToolbarShowLabel}`, false)), ( ContextKeyExpr.notEquals(`config.${NotebookSetting.globalToolbarShowLabel}`, 'never'))))
|
|
249
|
-
});
|
|
250
|
-
MenuRegistry.appendMenuItem(MenuId.NotebookCellListTop, {
|
|
251
|
-
command: {
|
|
252
|
-
id: INSERT_MARKDOWN_CELL_AT_TOP_COMMAND_ID,
|
|
253
|
-
title: '$(add) ' + ( localize(9428, "Markdown")),
|
|
254
|
-
tooltip: ( localize(9429, "Add Markdown Cell"))
|
|
255
|
-
},
|
|
256
|
-
order: 1,
|
|
257
|
-
group: 'inline',
|
|
258
|
-
when: ( ContextKeyExpr.and(( NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)), ( ContextKeyExpr.notEquals('config.notebook.experimental.insertToolbarAlignment', 'left'))))
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
export { InsertCellCommand, insertNewCell };
|