@codingame/monaco-vscode-chat-service-override 7.1.0 → 8.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/chat/browser/actions/chatAccessibilityHelp.js +86 -91
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +5 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +205 -115
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +61 -21
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +3 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +2 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +3 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +4 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +10 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +10 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +24 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +5 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +29 -108
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +76 -67
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +9 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +9 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +17 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +28 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +2 -3
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +17 -55
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +54 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +3 -4
- package/vscode/src/vs/workbench/contrib/chat/common/languageModelToolsService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +60 -25
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +6 -7
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +6 -5
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +24 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +9 -12
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +4 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +0 -17
|
@@ -2,14 +2,14 @@ import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellati
|
|
|
2
2
|
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
3
3
|
import { KeyMod, KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
4
4
|
import { isDiffEditor, isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
|
|
5
|
-
import {
|
|
5
|
+
import { ResourceTextEdit, IBulkEditService } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
|
|
6
6
|
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
7
7
|
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
8
8
|
import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
|
|
9
9
|
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
10
10
|
import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
|
|
11
11
|
import { CopyAction } from 'vscode/vscode/vs/editor/contrib/clipboard/browser/clipboard';
|
|
12
|
-
import {
|
|
12
|
+
import { localize2, localize } from 'vscode/vscode/vs/nls';
|
|
13
13
|
import { Action2, registerAction2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
14
14
|
import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService.service';
|
|
15
15
|
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
@@ -33,9 +33,10 @@ import { NOTEBOOK_EDITOR_ID, CellKind } from 'vscode/vscode/vs/workbench/contrib
|
|
|
33
33
|
import { ITerminalService, ITerminalEditorService, ITerminalGroupService } from 'vscode/vscode/vs/workbench/contrib/terminal/browser/terminal.service';
|
|
34
34
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
35
35
|
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
|
|
36
|
+
import { splitLines } from 'vscode/vscode/vs/base/common/strings';
|
|
37
|
+
import { CharCode } from 'vscode/vscode/vs/base/common/charCode';
|
|
36
38
|
import Severity$1 from 'vscode/vscode/vs/base/common/severity';
|
|
37
39
|
|
|
38
|
-
const _moduleId = "vs/workbench/contrib/chat/browser/actions/chatCodeblockActions";
|
|
39
40
|
function isCodeBlockActionContext(thing) {
|
|
40
41
|
return typeof thing === 'object' && thing !== null && 'code' in thing && 'element' in thing;
|
|
41
42
|
}
|
|
@@ -65,18 +66,152 @@ class ChatCodeBlockAction extends Action2 {
|
|
|
65
66
|
return this.runWithContext(accessor, context);
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
class InsertCodeBlockAction extends ChatCodeBlockAction {
|
|
70
|
+
async runWithContext(accessor, context) {
|
|
71
|
+
const editorService = accessor.get(IEditorService);
|
|
72
|
+
const textFileService = accessor.get(ITextFileService);
|
|
73
|
+
if (isResponseFiltered(context)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (editorService.activeEditorPane?.getId() === NOTEBOOK_EDITOR_ID) {
|
|
77
|
+
return this.handleNotebookEditor(accessor, editorService.activeEditorPane.getControl(), context);
|
|
78
|
+
}
|
|
79
|
+
let activeEditorControl = editorService.activeTextEditorControl;
|
|
80
|
+
if (isDiffEditor(activeEditorControl)) {
|
|
81
|
+
activeEditorControl = activeEditorControl.getOriginalEditor().hasTextFocus() ? activeEditorControl.getOriginalEditor() : activeEditorControl.getModifiedEditor();
|
|
82
|
+
}
|
|
83
|
+
if (!isCodeEditor(activeEditorControl)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!activeEditorControl.hasModel()) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const activeModelUri = activeEditorControl.getModel().uri;
|
|
90
|
+
const activeTextModel = textFileService.files.get(activeModelUri) ?? textFileService.untitled.get(activeModelUri);
|
|
91
|
+
if (!activeTextModel || activeTextModel.isReadonly()) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
await this.handleTextEditor(accessor, activeEditorControl, context);
|
|
95
|
+
}
|
|
96
|
+
async handleNotebookEditor(accessor, notebookEditor, context) {
|
|
97
|
+
if (!notebookEditor.hasModel()) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (notebookEditor.isReadOnly) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (notebookEditor.activeCodeEditor?.hasTextFocus()) {
|
|
104
|
+
const codeEditor = notebookEditor.activeCodeEditor;
|
|
105
|
+
if (codeEditor.hasModel()) {
|
|
106
|
+
return this.handleTextEditor(accessor, codeEditor, context);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const languageService = accessor.get(ILanguageService);
|
|
110
|
+
const focusRange = notebookEditor.getFocus();
|
|
111
|
+
const next = Math.max(focusRange.end - 1, 0);
|
|
112
|
+
insertCell(languageService, notebookEditor, next, CellKind.Code, 'below', context.code, true);
|
|
113
|
+
this.notifyUserAction(accessor, context);
|
|
114
|
+
}
|
|
115
|
+
async computeEdits(accessor, codeEditor, codeBlockActionContext) {
|
|
116
|
+
const activeModel = codeEditor.getModel();
|
|
117
|
+
const range = codeEditor.getSelection() ?? ( (new Range(activeModel.getLineCount(), 1, activeModel.getLineCount(), 1)));
|
|
118
|
+
const text = reindent(codeBlockActionContext.code, activeModel, range.startLineNumber);
|
|
119
|
+
return [( (new ResourceTextEdit(activeModel.uri, { range, text })))];
|
|
120
|
+
}
|
|
121
|
+
async handleTextEditor(accessor, codeEditor, codeBlockActionContext) {
|
|
122
|
+
const bulkEditService = accessor.get(IBulkEditService);
|
|
123
|
+
const codeEditorService = accessor.get(ICodeEditorService);
|
|
124
|
+
this.notifyUserAction(accessor, codeBlockActionContext);
|
|
125
|
+
const activeModel = codeEditor.getModel();
|
|
126
|
+
const mappedEdits = await this.computeEdits(accessor, codeEditor, codeBlockActionContext);
|
|
127
|
+
await bulkEditService.apply(mappedEdits);
|
|
128
|
+
codeEditorService.listCodeEditors().find(editor => editor.getModel()?.uri.toString() === ( (activeModel.uri.toString())))?.focus();
|
|
129
|
+
}
|
|
130
|
+
notifyUserAction(accessor, context) {
|
|
131
|
+
if (isResponseVM(context.element)) {
|
|
132
|
+
const chatService = accessor.get(IChatService);
|
|
133
|
+
chatService.notifyUserAction({
|
|
134
|
+
agentId: context.element.agent?.id,
|
|
135
|
+
command: context.element.slashCommand?.name,
|
|
136
|
+
sessionId: context.element.sessionId,
|
|
137
|
+
requestId: context.element.requestId,
|
|
138
|
+
result: context.element.result,
|
|
139
|
+
action: {
|
|
140
|
+
kind: 'insert',
|
|
141
|
+
codeBlockIndex: context.codeBlockIndex,
|
|
142
|
+
totalCharacters: context.code.length,
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function reindent(codeBlockContent, model, seletionStartLine) {
|
|
149
|
+
const newContent = splitLines(codeBlockContent);
|
|
150
|
+
if (newContent.length === 0) {
|
|
151
|
+
return codeBlockContent;
|
|
152
|
+
}
|
|
153
|
+
const formattingOptions = model.getFormattingOptions();
|
|
154
|
+
const codeIndentLevel = computeIndentation(model.getLineContent(seletionStartLine), formattingOptions.tabSize).level;
|
|
155
|
+
const indents = ( (newContent.map(line => computeIndentation(line, formattingOptions.tabSize))));
|
|
156
|
+
const newContentIndentLevel = indents.reduce((min, indent, index) => {
|
|
157
|
+
if (indent.length !== newContent[index].length) {
|
|
158
|
+
return Math.min(indent.level, min);
|
|
159
|
+
}
|
|
160
|
+
return min;
|
|
161
|
+
}, Number.MAX_VALUE);
|
|
162
|
+
if (newContentIndentLevel === Number.MAX_VALUE || newContentIndentLevel === codeIndentLevel) {
|
|
163
|
+
return codeBlockContent;
|
|
164
|
+
}
|
|
165
|
+
const newLines = [];
|
|
166
|
+
for (let i = 0; i < newContent.length; i++) {
|
|
167
|
+
const { level, length } = indents[i];
|
|
168
|
+
const newLevel = Math.max(0, codeIndentLevel + level - newContentIndentLevel);
|
|
169
|
+
const newIndentation = formattingOptions.insertSpaces ? ' '.repeat(formattingOptions.tabSize * newLevel) : '\t'.repeat(newLevel);
|
|
170
|
+
newLines.push(newIndentation + newContent[i].substring(length));
|
|
171
|
+
}
|
|
172
|
+
return newLines.join('\n');
|
|
173
|
+
}
|
|
174
|
+
function computeIndentation(line, tabSize) {
|
|
175
|
+
let nSpaces = 0;
|
|
176
|
+
let level = 0;
|
|
177
|
+
let i = 0;
|
|
178
|
+
let length = 0;
|
|
179
|
+
const len = line.length;
|
|
180
|
+
while (i < len) {
|
|
181
|
+
const chCode = line.charCodeAt(i);
|
|
182
|
+
if (chCode === CharCode.Space) {
|
|
183
|
+
nSpaces++;
|
|
184
|
+
if (nSpaces === tabSize) {
|
|
185
|
+
level++;
|
|
186
|
+
nSpaces = 0;
|
|
187
|
+
length = i + 1;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else if (chCode === CharCode.Tab) {
|
|
191
|
+
level++;
|
|
192
|
+
nSpaces = 0;
|
|
193
|
+
length = i + 1;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
i++;
|
|
199
|
+
}
|
|
200
|
+
return { level, length };
|
|
201
|
+
}
|
|
68
202
|
function registerChatCodeBlockActions() {
|
|
69
203
|
registerAction2(class CopyCodeBlockAction extends Action2 {
|
|
70
204
|
constructor() {
|
|
71
205
|
super({
|
|
72
206
|
id: 'workbench.action.chat.copyCodeBlock',
|
|
73
|
-
title: (
|
|
207
|
+
title: ( localize2(7095, "Copy")),
|
|
74
208
|
f1: false,
|
|
75
209
|
category: CHAT_CATEGORY,
|
|
76
210
|
icon: Codicon.copy,
|
|
77
211
|
menu: {
|
|
78
212
|
id: MenuId.ChatCodeBlock,
|
|
79
|
-
group: 'navigation'
|
|
213
|
+
group: 'navigation',
|
|
214
|
+
order: 30
|
|
80
215
|
}
|
|
81
216
|
});
|
|
82
217
|
}
|
|
@@ -91,6 +226,7 @@ function registerChatCodeBlockActions() {
|
|
|
91
226
|
const chatService = accessor.get(IChatService);
|
|
92
227
|
chatService.notifyUserAction({
|
|
93
228
|
agentId: context.element.agent?.id,
|
|
229
|
+
command: context.element.slashCommand?.name,
|
|
94
230
|
sessionId: context.element.sessionId,
|
|
95
231
|
requestId: context.element.requestId,
|
|
96
232
|
result: context.element.result,
|
|
@@ -129,6 +265,7 @@ function registerChatCodeBlockActions() {
|
|
|
129
265
|
if (element) {
|
|
130
266
|
chatService.notifyUserAction({
|
|
131
267
|
agentId: element.agent?.id,
|
|
268
|
+
command: element.slashCommand?.name,
|
|
132
269
|
sessionId: element.sessionId,
|
|
133
270
|
requestId: element.requestId,
|
|
134
271
|
result: element.result,
|
|
@@ -148,19 +285,20 @@ function registerChatCodeBlockActions() {
|
|
|
148
285
|
}
|
|
149
286
|
return false;
|
|
150
287
|
});
|
|
151
|
-
registerAction2(class
|
|
288
|
+
registerAction2(class SmartApplyInEditorAction extends InsertCodeBlockAction {
|
|
152
289
|
constructor() {
|
|
153
290
|
super({
|
|
154
|
-
id: 'workbench.action.chat.
|
|
155
|
-
title: (
|
|
291
|
+
id: 'workbench.action.chat.applyInEditor',
|
|
292
|
+
title: ( localize2(7096, "Apply in Editor")),
|
|
156
293
|
precondition: CONTEXT_CHAT_ENABLED,
|
|
157
294
|
f1: true,
|
|
158
295
|
category: CHAT_CATEGORY,
|
|
159
|
-
icon: Codicon.
|
|
296
|
+
icon: Codicon.sparkle,
|
|
160
297
|
menu: {
|
|
161
298
|
id: MenuId.ChatCodeBlock,
|
|
162
299
|
group: 'navigation',
|
|
163
|
-
when: CONTEXT_IN_CHAT_SESSION
|
|
300
|
+
when: CONTEXT_IN_CHAT_SESSION,
|
|
301
|
+
order: 10
|
|
164
302
|
},
|
|
165
303
|
keybinding: {
|
|
166
304
|
when: ( (ContextKeyExpr.or(
|
|
@@ -173,76 +311,24 @@ function registerChatCodeBlockActions() {
|
|
|
173
311
|
},
|
|
174
312
|
});
|
|
175
313
|
}
|
|
176
|
-
async
|
|
177
|
-
const editorService = accessor.get(IEditorService);
|
|
178
|
-
const textFileService = accessor.get(ITextFileService);
|
|
179
|
-
if (isResponseFiltered(context)) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
if (editorService.activeEditorPane?.getId() === NOTEBOOK_EDITOR_ID) {
|
|
183
|
-
return this.handleNotebookEditor(accessor, editorService.activeEditorPane.getControl(), context);
|
|
184
|
-
}
|
|
185
|
-
let activeEditorControl = editorService.activeTextEditorControl;
|
|
186
|
-
if (isDiffEditor(activeEditorControl)) {
|
|
187
|
-
activeEditorControl = activeEditorControl.getOriginalEditor().hasTextFocus() ? activeEditorControl.getOriginalEditor() : activeEditorControl.getModifiedEditor();
|
|
188
|
-
}
|
|
189
|
-
if (!isCodeEditor(activeEditorControl)) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
const activeModel = activeEditorControl.getModel();
|
|
193
|
-
if (!activeModel) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const activeTextModel = textFileService.files.get(activeModel.uri) ?? textFileService.untitled.get(activeModel.uri);
|
|
197
|
-
if (!activeTextModel || activeTextModel.isReadonly()) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
await this.handleTextEditor(accessor, activeEditorControl, activeModel, context);
|
|
201
|
-
}
|
|
202
|
-
async handleNotebookEditor(accessor, notebookEditor, context) {
|
|
203
|
-
if (!notebookEditor.hasModel()) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (notebookEditor.isReadOnly) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (notebookEditor.activeCodeEditor?.hasTextFocus()) {
|
|
210
|
-
const codeEditor = notebookEditor.activeCodeEditor;
|
|
211
|
-
const textModel = codeEditor.getModel();
|
|
212
|
-
if (textModel) {
|
|
213
|
-
return this.handleTextEditor(accessor, codeEditor, textModel, context);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
const languageService = accessor.get(ILanguageService);
|
|
217
|
-
const focusRange = notebookEditor.getFocus();
|
|
218
|
-
const next = Math.max(focusRange.end - 1, 0);
|
|
219
|
-
insertCell(languageService, notebookEditor, next, CellKind.Code, 'below', context.code, true);
|
|
220
|
-
this.notifyUserAction(accessor, context);
|
|
221
|
-
}
|
|
222
|
-
async handleTextEditor(accessor, codeEditor, activeModel, codeBlockActionContext) {
|
|
223
|
-
this.notifyUserAction(accessor, codeBlockActionContext);
|
|
224
|
-
const bulkEditService = accessor.get(IBulkEditService);
|
|
225
|
-
const codeEditorService = accessor.get(ICodeEditorService);
|
|
314
|
+
async computeEdits(accessor, codeEditor, codeBlockActionContext) {
|
|
226
315
|
const progressService = accessor.get(IProgressService);
|
|
227
316
|
const notificationService = accessor.get(INotificationService);
|
|
317
|
+
const activeModel = codeEditor.getModel();
|
|
228
318
|
const mappedEditsProviders = accessor.get(ILanguageFeaturesService).mappedEditsProvider.ordered(activeModel);
|
|
229
|
-
let mappedEdits = null;
|
|
230
319
|
if (mappedEditsProviders.length > 0) {
|
|
231
320
|
const docRefs = [];
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
]);
|
|
245
|
-
}
|
|
321
|
+
const currentDocUri = activeModel.uri;
|
|
322
|
+
const currentDocVersion = activeModel.getVersionId();
|
|
323
|
+
const selections = codeEditor.getSelections();
|
|
324
|
+
if (selections.length > 0) {
|
|
325
|
+
docRefs.push([
|
|
326
|
+
{
|
|
327
|
+
uri: currentDocUri,
|
|
328
|
+
version: currentDocVersion,
|
|
329
|
+
ranges: selections,
|
|
330
|
+
}
|
|
331
|
+
]);
|
|
246
332
|
}
|
|
247
333
|
const usedDocuments = getUsedDocuments(codeBlockActionContext);
|
|
248
334
|
if (usedDocuments) {
|
|
@@ -250,61 +336,62 @@ function registerChatCodeBlockActions() {
|
|
|
250
336
|
}
|
|
251
337
|
const cancellationTokenSource = ( (new CancellationTokenSource()));
|
|
252
338
|
try {
|
|
253
|
-
|
|
254
|
-
progress.report({ message: ( localizeWithPath(_moduleId, 2, "Applying code block...")) });
|
|
339
|
+
const edits = await progressService.withProgress({ location: ProgressLocation.Notification, delay: 500, sticky: true, cancellable: true }, async (progress) => {
|
|
255
340
|
for (const provider of mappedEditsProviders) {
|
|
341
|
+
progress.report({ message: ( localize(7097, "Applying code block using {0}...", provider.displayName)) });
|
|
256
342
|
const mappedEdits = await provider.provideMappedEdits(activeModel, [codeBlockActionContext.code], { documents: docRefs }, cancellationTokenSource.token);
|
|
257
343
|
if (mappedEdits) {
|
|
258
344
|
return mappedEdits;
|
|
259
345
|
}
|
|
260
346
|
}
|
|
261
|
-
return
|
|
347
|
+
return undefined;
|
|
262
348
|
}, () => cancellationTokenSource.cancel());
|
|
349
|
+
if (edits) {
|
|
350
|
+
return edits;
|
|
351
|
+
}
|
|
263
352
|
}
|
|
264
353
|
catch (e) {
|
|
265
|
-
notificationService.notify({ severity: Severity$1.Error, message: (
|
|
354
|
+
notificationService.notify({ severity: Severity$1.Error, message: ( localize(7098, "Failed to apply code block: {0}", e.message)) });
|
|
266
355
|
}
|
|
267
356
|
finally {
|
|
268
357
|
cancellationTokenSource.dispose();
|
|
269
358
|
}
|
|
270
359
|
}
|
|
271
|
-
|
|
272
|
-
console.log('Mapped edits:', mappedEdits);
|
|
273
|
-
await bulkEditService.apply(mappedEdits);
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
const activeSelection = codeEditor.getSelection() ?? ( (new Range(activeModel.getLineCount(), 1, activeModel.getLineCount(), 1)));
|
|
277
|
-
await bulkEditService.apply([
|
|
278
|
-
( (new ResourceTextEdit(activeModel.uri, {
|
|
279
|
-
range: activeSelection,
|
|
280
|
-
text: codeBlockActionContext.code,
|
|
281
|
-
}))),
|
|
282
|
-
]);
|
|
283
|
-
}
|
|
284
|
-
codeEditorService.listCodeEditors().find(editor => editor.getModel()?.uri.toString() === ( (activeModel.uri.toString())))?.focus();
|
|
360
|
+
return super.computeEdits(accessor, codeEditor, codeBlockActionContext);
|
|
285
361
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
362
|
+
});
|
|
363
|
+
registerAction2(class SmartApplyInEditorAction extends InsertCodeBlockAction {
|
|
364
|
+
constructor() {
|
|
365
|
+
super({
|
|
366
|
+
id: 'workbench.action.chat.insertCodeBlock',
|
|
367
|
+
title: ( localize2(7099, "Insert At Cursor")),
|
|
368
|
+
precondition: CONTEXT_CHAT_ENABLED,
|
|
369
|
+
f1: true,
|
|
370
|
+
category: CHAT_CATEGORY,
|
|
371
|
+
icon: Codicon.insert,
|
|
372
|
+
menu: {
|
|
373
|
+
id: MenuId.ChatCodeBlock,
|
|
374
|
+
group: 'navigation',
|
|
375
|
+
when: CONTEXT_IN_CHAT_SESSION,
|
|
376
|
+
order: 20
|
|
377
|
+
},
|
|
378
|
+
keybinding: {
|
|
379
|
+
when: ( (ContextKeyExpr.or(
|
|
380
|
+
(ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, (CONTEXT_IN_CHAT_INPUT.negate()))),
|
|
381
|
+
accessibleViewInCodeBlock
|
|
382
|
+
))),
|
|
383
|
+
primary: KeyMod.CtrlCmd | KeyCode.Enter,
|
|
384
|
+
mac: { primary: KeyMod.WinCtrl | KeyCode.Enter },
|
|
385
|
+
weight: KeybindingWeight.ExternalExtension + 1
|
|
386
|
+
},
|
|
387
|
+
});
|
|
301
388
|
}
|
|
302
389
|
});
|
|
303
390
|
registerAction2(class InsertIntoNewFileAction extends ChatCodeBlockAction {
|
|
304
391
|
constructor() {
|
|
305
392
|
super({
|
|
306
393
|
id: 'workbench.action.chat.insertIntoNewFile',
|
|
307
|
-
title: (
|
|
394
|
+
title: ( localize2(7100, "Insert into New File")),
|
|
308
395
|
precondition: CONTEXT_CHAT_ENABLED,
|
|
309
396
|
f1: true,
|
|
310
397
|
category: CHAT_CATEGORY,
|
|
@@ -312,7 +399,8 @@ function registerChatCodeBlockActions() {
|
|
|
312
399
|
menu: {
|
|
313
400
|
id: MenuId.ChatCodeBlock,
|
|
314
401
|
group: 'navigation',
|
|
315
|
-
isHiddenByDefault: true
|
|
402
|
+
isHiddenByDefault: true,
|
|
403
|
+
order: 40,
|
|
316
404
|
}
|
|
317
405
|
});
|
|
318
406
|
}
|
|
@@ -326,6 +414,7 @@ function registerChatCodeBlockActions() {
|
|
|
326
414
|
if (isResponseVM(context.element)) {
|
|
327
415
|
chatService.notifyUserAction({
|
|
328
416
|
agentId: context.element.agent?.id,
|
|
417
|
+
command: context.element.slashCommand?.name,
|
|
329
418
|
sessionId: context.element.sessionId,
|
|
330
419
|
requestId: context.element.requestId,
|
|
331
420
|
result: context.element.result,
|
|
@@ -352,7 +441,7 @@ function registerChatCodeBlockActions() {
|
|
|
352
441
|
constructor() {
|
|
353
442
|
super({
|
|
354
443
|
id: 'workbench.action.chat.runInTerminal',
|
|
355
|
-
title: (
|
|
444
|
+
title: ( localize2(7101, "Insert into Terminal")),
|
|
356
445
|
precondition: CONTEXT_CHAT_ENABLED,
|
|
357
446
|
f1: true,
|
|
358
447
|
category: CHAT_CATEGORY,
|
|
@@ -410,6 +499,7 @@ function registerChatCodeBlockActions() {
|
|
|
410
499
|
if (isResponseVM(context.element)) {
|
|
411
500
|
chatService.notifyUserAction({
|
|
412
501
|
agentId: context.element.agent?.id,
|
|
502
|
+
command: context.element.slashCommand?.name,
|
|
413
503
|
sessionId: context.element.sessionId,
|
|
414
504
|
requestId: context.element.requestId,
|
|
415
505
|
result: context.element.result,
|
|
@@ -451,7 +541,7 @@ function registerChatCodeBlockActions() {
|
|
|
451
541
|
constructor() {
|
|
452
542
|
super({
|
|
453
543
|
id: 'workbench.action.chat.nextCodeBlock',
|
|
454
|
-
title: (
|
|
544
|
+
title: ( localize2(7102, "Next Code Block")),
|
|
455
545
|
keybinding: {
|
|
456
546
|
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown,
|
|
457
547
|
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown, },
|
|
@@ -471,7 +561,7 @@ function registerChatCodeBlockActions() {
|
|
|
471
561
|
constructor() {
|
|
472
562
|
super({
|
|
473
563
|
id: 'workbench.action.chat.previousCodeBlock',
|
|
474
|
-
title: (
|
|
564
|
+
title: ( localize2(7103, "Previous Code Block")),
|
|
475
565
|
keybinding: {
|
|
476
566
|
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp,
|
|
477
567
|
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp, },
|
|
@@ -527,7 +617,7 @@ function registerChatCodeCompareBlockActions() {
|
|
|
527
617
|
constructor() {
|
|
528
618
|
super({
|
|
529
619
|
id: 'workbench.action.chat.applyCompareEdits',
|
|
530
|
-
title: (
|
|
620
|
+
title: ( localize2(7104, "Apply Edits")),
|
|
531
621
|
f1: false,
|
|
532
622
|
category: CHAT_CATEGORY,
|
|
533
623
|
icon: Codicon.check,
|
|
@@ -557,7 +647,7 @@ function registerChatCodeCompareBlockActions() {
|
|
|
557
647
|
constructor() {
|
|
558
648
|
super({
|
|
559
649
|
id: 'workbench.action.chat.discardCompareEdits',
|
|
560
|
-
title: (
|
|
650
|
+
title: ( localize2(7105, "Discard Edits")),
|
|
561
651
|
f1: false,
|
|
562
652
|
category: CHAT_CATEGORY,
|
|
563
653
|
icon: Codicon.trash,
|