@codingame/monaco-vscode-xterm-addons-common 37.2.0 → 37.3.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/terminal/browser/xterm/xtermTerminal.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.d.ts +58 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.js +462 -0
- package/vscode/src/vs/base/browser/htmlToMarkdown.d.ts +0 -1
- package/vscode/src/vs/base/browser/htmlToMarkdown.js +0 -144
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +0 -59
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +0 -482
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +0 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +0 -95
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +0 -24
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +0 -355
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +0 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +0 -81
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +0 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +0 -181
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +0 -75
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +0 -622
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.d.ts +0 -71
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.js +0 -800
- package/vscode/src/vs/workbench/contrib/git/common/utils.d.ts +0 -8
- package/vscode/src/vs/workbench/contrib/git/common/utils.js +0 -105
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.d.ts +0 -18
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.js +0 -51
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.d.ts +0 -79
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +0 -652
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.d.ts +0 -64
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +0 -564
package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.js
DELETED
|
@@ -1,800 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { alert, status } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/aria/aria';
|
|
4
|
-
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
5
|
-
import { VSDataTransfer, createStringDataTransferItem } from '@codingame/monaco-vscode-api/vscode/vs/base/common/dataTransfer';
|
|
6
|
-
import { convertHtmlToMarkdown } from '../../../../../../../base/browser/htmlToMarkdown.js';
|
|
7
|
-
import { HierarchicalKind } from '@codingame/monaco-vscode-api/vscode/vs/base/common/hierarchicalKind';
|
|
8
|
-
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
9
|
-
import { revive } from '@codingame/monaco-vscode-api/vscode/vs/base/common/marshalling';
|
|
10
|
-
import { Mimes } from '@codingame/monaco-vscode-api/vscode/vs/base/common/mime';
|
|
11
|
-
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
12
|
-
import { joinPath, basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
13
|
-
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
14
|
-
import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position';
|
|
15
|
-
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
16
|
-
import { SymbolKinds, DocumentPasteTriggerKind } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
|
|
17
|
-
import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
|
|
18
|
-
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
|
|
19
|
-
import { IOutlineModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/documentSymbols/browser/outlineModel.service';
|
|
20
|
-
import { getDefinitionsAtPosition } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/gotoSymbol/browser/goToSymbol';
|
|
21
|
-
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
22
|
-
import { IEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service';
|
|
23
|
-
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
24
|
-
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
25
|
-
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
26
|
-
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
27
|
-
import { isProposedApiEnabled } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions';
|
|
28
|
-
import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
29
|
-
import { toPasteVariableEntry, ChatPasteAttachmentMetadata, isImageVariableEntry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/attachments/chatVariableEntries';
|
|
30
|
-
import { chatVariableLeader } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/requestParser/chatParserTypes';
|
|
31
|
-
import { IChatPasteTargetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
32
|
-
import { isChatInputModel, ChatConfiguration, chatInputSchemes } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
33
|
-
import { cleanupOldImages, createFileForMedia, resizeImage, imageToHash } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatImageUtils';
|
|
34
|
-
|
|
35
|
-
const COPY_MIME_TYPES = "application/vnd.code.additional-editor-data";
|
|
36
|
-
const pastedTextArtifactDefaultMinLength = 10000;
|
|
37
|
-
const CHAT_ATTACHMENT_MIME_TYPE = "application/vnd.chat.attachment+json";
|
|
38
|
-
const GITHUB_ISSUE_OR_PULL_REQUEST_URL_PATTERN = /\bhttps?:\/\/(?:www\.)?github\.com\/(?<owner>[\w.-]+)\/(?<repo>[\w.-]+)\/(?<kind>issues|pull)\/(?<number>\d+)(?![\w-])/gi;
|
|
39
|
-
let PasteImageProvider = class PasteImageProvider {
|
|
40
|
-
constructor(
|
|
41
|
-
pasteTargetService,
|
|
42
|
-
extensionService,
|
|
43
|
-
fileService,
|
|
44
|
-
environmentService,
|
|
45
|
-
logService
|
|
46
|
-
) {
|
|
47
|
-
this.pasteTargetService = pasteTargetService;
|
|
48
|
-
this.extensionService = extensionService;
|
|
49
|
-
this.fileService = fileService;
|
|
50
|
-
this.environmentService = environmentService;
|
|
51
|
-
this.logService = logService;
|
|
52
|
-
this.kind = ( new HierarchicalKind("chat.attach.image"));
|
|
53
|
-
this.providedPasteEditKinds = [this.kind];
|
|
54
|
-
this.copyMimeTypes = [];
|
|
55
|
-
this.pasteMimeTypes = ["image/*"];
|
|
56
|
-
this.imagesFolder = joinPath(this.environmentService.workspaceStorageHome, "vscode-chat-images");
|
|
57
|
-
cleanupOldImages(this.fileService, this.logService, this.imagesFolder);
|
|
58
|
-
}
|
|
59
|
-
async provideDocumentPasteEdits(model, ranges, dataTransfer, context, token) {
|
|
60
|
-
if (!( this.extensionService.extensions.some(ext => isProposedApiEnabled(ext, "chatReferenceBinaryData")))) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const supportedMimeTypes = [
|
|
64
|
-
"image/png",
|
|
65
|
-
"image/jpeg",
|
|
66
|
-
"image/jpg",
|
|
67
|
-
"image/bmp",
|
|
68
|
-
"image/gif",
|
|
69
|
-
"image/tiff"
|
|
70
|
-
];
|
|
71
|
-
let mimeType;
|
|
72
|
-
let imageItem;
|
|
73
|
-
for (const type of supportedMimeTypes) {
|
|
74
|
-
imageItem = dataTransfer.get(type);
|
|
75
|
-
if (imageItem) {
|
|
76
|
-
mimeType = type;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (!imageItem || !mimeType) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const currClipboard = await imageItem.asFile()?.data();
|
|
84
|
-
if (token.isCancellationRequested || !currClipboard) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const target = this.pasteTargetService.getTarget(model.uri);
|
|
88
|
-
if (!target) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const attachedVariables = target.attachments;
|
|
92
|
-
const displayName = ( localize(10028, "Pasted Image"));
|
|
93
|
-
let tempDisplayName = displayName;
|
|
94
|
-
for (let appendValue = 2; ( attachedVariables.some(attachment => attachment.name === tempDisplayName)); appendValue++)
|
|
95
|
-
{
|
|
96
|
-
tempDisplayName = `${displayName} ${appendValue}`;
|
|
97
|
-
}
|
|
98
|
-
const fileReference = await createFileForMedia(this.fileService, this.imagesFolder, currClipboard, mimeType);
|
|
99
|
-
if (token.isCancellationRequested || !fileReference) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const scaledImageData = await resizeImage(currClipboard);
|
|
103
|
-
if (token.isCancellationRequested || !scaledImageData) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
const scaledImageContext = await getImageAttachContext(scaledImageData, mimeType, token, tempDisplayName, fileReference);
|
|
107
|
-
if (token.isCancellationRequested || !scaledImageContext) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const currentContextIds = ( new Set(( target.attachments.map(attachment => attachment.id))));
|
|
111
|
-
if (( currentContextIds.has(scaledImageContext.id))) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const edit = createCustomPasteEdit(model, [scaledImageContext], mimeType, this.kind, ( localize(10029, "Pasted Image Attachment")), this.pasteTargetService);
|
|
115
|
-
return createEditSession(edit);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
PasteImageProvider = ( __decorate([( __param(2, IFileService)), ( __param(3, IEnvironmentService)), ( __param(4, ILogService))], PasteImageProvider));
|
|
119
|
-
async function getImageAttachContext(data, mimeType, token, displayName, resource) {
|
|
120
|
-
const imageHash = await imageToHash(data);
|
|
121
|
-
if (token.isCancellationRequested) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
kind: "image",
|
|
126
|
-
value: data,
|
|
127
|
-
id: imageHash,
|
|
128
|
-
name: displayName,
|
|
129
|
-
icon: Codicon.fileMedia,
|
|
130
|
-
mimeType,
|
|
131
|
-
isPasted: true,
|
|
132
|
-
references: [{
|
|
133
|
-
reference: resource,
|
|
134
|
-
kind: "reference"
|
|
135
|
-
}]
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function isImage(array) {
|
|
139
|
-
if (array.length < 4) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
const identifier = {
|
|
143
|
-
png: [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A],
|
|
144
|
-
jpeg: [0xFF, 0xD8, 0xFF],
|
|
145
|
-
bmp: [0x42, 0x4D],
|
|
146
|
-
gif: [0x47, 0x49, 0x46, 0x38],
|
|
147
|
-
tiff: [0x49, 0x49, 0x2A, 0x00]
|
|
148
|
-
};
|
|
149
|
-
return ( ( Object.values(identifier)).some(signature => signature.every((byte, index) => array[index] === byte)));
|
|
150
|
-
}
|
|
151
|
-
let CopyTextProvider = class CopyTextProvider {
|
|
152
|
-
constructor(modelService, languageFeaturesService, outlineModelService) {
|
|
153
|
-
this.modelService = modelService;
|
|
154
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
155
|
-
this.outlineModelService = outlineModelService;
|
|
156
|
-
this.providedPasteEditKinds = [];
|
|
157
|
-
this.copyMimeTypes = [COPY_MIME_TYPES];
|
|
158
|
-
this.pasteMimeTypes = [];
|
|
159
|
-
}
|
|
160
|
-
async prepareDocumentPaste(model, ranges, dataTransfer, token) {
|
|
161
|
-
if (isChatInputModel(model.uri)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const customDataTransfer = ( new VSDataTransfer());
|
|
165
|
-
const data = {
|
|
166
|
-
range: ranges[0],
|
|
167
|
-
uri: model.uri.toJSON()
|
|
168
|
-
};
|
|
169
|
-
customDataTransfer.append(COPY_MIME_TYPES, createStringDataTransferItem(JSON.stringify(data)));
|
|
170
|
-
const text = dataTransfer.get(Mimes.text);
|
|
171
|
-
if (text && ranges.length) {
|
|
172
|
-
void this.primeSymbolReferenceCache(model, ranges[0], text, token);
|
|
173
|
-
}
|
|
174
|
-
return customDataTransfer;
|
|
175
|
-
}
|
|
176
|
-
async primeSymbolReferenceCache(model, range, textItem, token) {
|
|
177
|
-
const copiedText = model.getValueInRange(range);
|
|
178
|
-
if (range.startLineNumber !== range.endLineNumber) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (token.isCancellationRequested || !identifierPattern.test(copiedText)) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
cacheSymbolReference(model.uri, range, copiedText, resolveSymbolReference(
|
|
185
|
-
this.modelService,
|
|
186
|
-
this.languageFeaturesService,
|
|
187
|
-
this.outlineModelService,
|
|
188
|
-
model.uri,
|
|
189
|
-
range,
|
|
190
|
-
copiedText,
|
|
191
|
-
token
|
|
192
|
-
));
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
CopyTextProvider = ( __decorate([( __param(0, IModelService)), ( __param(1, ILanguageFeaturesService)), ( __param(2, IOutlineModelService))], CopyTextProvider));
|
|
196
|
-
let CopyAttachmentsProvider = class CopyAttachmentsProvider {
|
|
197
|
-
constructor(pasteTargetService) {
|
|
198
|
-
this.pasteTargetService = pasteTargetService;
|
|
199
|
-
this.kind = ( new HierarchicalKind("chat.attach.attachments"));
|
|
200
|
-
this.providedPasteEditKinds = [this.kind];
|
|
201
|
-
this.copyMimeTypes = [CHAT_ATTACHMENT_MIME_TYPE];
|
|
202
|
-
this.pasteMimeTypes = [CHAT_ATTACHMENT_MIME_TYPE];
|
|
203
|
-
}
|
|
204
|
-
async prepareDocumentPaste(model, _ranges, _dataTransfer, _token) {
|
|
205
|
-
const target = this.pasteTargetService.getTarget(model.uri);
|
|
206
|
-
if (!target) {
|
|
207
|
-
return undefined;
|
|
208
|
-
}
|
|
209
|
-
const dynamicVariables = target.inlineReferences;
|
|
210
|
-
const referencedIds = ( new Set(( dynamicVariables.map(variable => variable.id))));
|
|
211
|
-
const attachments = ( target.attachments.map(attachment => attachment.range && !( referencedIds.has(attachment.id)) ? {
|
|
212
|
-
...attachment,
|
|
213
|
-
range: undefined
|
|
214
|
-
} : attachment));
|
|
215
|
-
if (attachments.length === 0 && dynamicVariables.length === 0) {
|
|
216
|
-
return undefined;
|
|
217
|
-
}
|
|
218
|
-
const result = ( new VSDataTransfer());
|
|
219
|
-
result.append(CHAT_ATTACHMENT_MIME_TYPE, createStringDataTransferItem(JSON.stringify({
|
|
220
|
-
attachments,
|
|
221
|
-
dynamicVariables
|
|
222
|
-
})));
|
|
223
|
-
return result;
|
|
224
|
-
}
|
|
225
|
-
async provideDocumentPasteEdits(model, _ranges, dataTransfer, _context, token) {
|
|
226
|
-
const target = this.pasteTargetService.getTarget(model.uri);
|
|
227
|
-
if (!target) {
|
|
228
|
-
return undefined;
|
|
229
|
-
}
|
|
230
|
-
const text = dataTransfer.get(Mimes.text);
|
|
231
|
-
const data = dataTransfer.get(CHAT_ATTACHMENT_MIME_TYPE);
|
|
232
|
-
const rawData = await data?.asString();
|
|
233
|
-
const textdata = await text?.asString();
|
|
234
|
-
if (textdata === undefined || rawData === undefined) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
if (token.isCancellationRequested) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
let pastedData;
|
|
241
|
-
try {
|
|
242
|
-
pastedData = revive(JSON.parse(rawData));
|
|
243
|
-
} catch {}
|
|
244
|
-
if (!Array.isArray(pastedData?.attachments) && !Array.isArray(pastedData?.dynamicVariables)) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
const edit = {
|
|
248
|
-
insertText: textdata,
|
|
249
|
-
title: ( localize(10030, "Insert Prompt & Attachments")),
|
|
250
|
-
kind: this.kind,
|
|
251
|
-
handledMimeType: CHAT_ATTACHMENT_MIME_TYPE,
|
|
252
|
-
additionalEdit: {
|
|
253
|
-
edits: []
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
edit.additionalEdit?.edits.push({
|
|
257
|
-
resource: model.uri,
|
|
258
|
-
redo: () => {
|
|
259
|
-
target.addAttachments(pastedData.attachments);
|
|
260
|
-
for (const dynamicVariable of pastedData.dynamicVariables) {
|
|
261
|
-
target.addInlineReference(dynamicVariable);
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
undo: () => {
|
|
265
|
-
target.removeAttachments(( pastedData.attachments.map(c => c.id)));
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
return createEditSession(edit);
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
CopyAttachmentsProvider = ( __decorate([( __param(0, IChatPasteTargetService))], CopyAttachmentsProvider));
|
|
272
|
-
function getGitHubIssueOrPullRequestAttachments(input, metadata) {
|
|
273
|
-
const attachments = [];
|
|
274
|
-
const ids = ( new Set());
|
|
275
|
-
for (const match of input.matchAll(GITHUB_ISSUE_OR_PULL_REQUEST_URL_PATTERN)) {
|
|
276
|
-
const groups = match.groups;
|
|
277
|
-
const number = Number(groups?.["number"]);
|
|
278
|
-
if (!groups || !Number.isSafeInteger(number) || number <= 0) {
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
const owner = groups["owner"];
|
|
282
|
-
const repo = groups["repo"];
|
|
283
|
-
const kind = groups["kind"].toLowerCase();
|
|
284
|
-
const uri = `https://github.com/${owner}/${repo}/${kind}/${number}`;
|
|
285
|
-
const id = `github-context:${uri}`;
|
|
286
|
-
if (( ids.has(id))) {
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
ids.add(id);
|
|
290
|
-
attachments.push({
|
|
291
|
-
kind: "generic",
|
|
292
|
-
id,
|
|
293
|
-
icon: kind === "issues" ? Codicon.issues : Codicon.gitPullRequest,
|
|
294
|
-
name: `${owner}/${repo}#${number}`,
|
|
295
|
-
value: `GitHub context: ${uri}`,
|
|
296
|
-
_meta: metadata
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
return attachments;
|
|
300
|
-
}
|
|
301
|
-
class PasteTextProvider {
|
|
302
|
-
constructor(pasteTargetService, modelService, logService, configurationService) {
|
|
303
|
-
this.pasteTargetService = pasteTargetService;
|
|
304
|
-
this.modelService = modelService;
|
|
305
|
-
this.logService = logService;
|
|
306
|
-
this.configurationService = configurationService;
|
|
307
|
-
this.kind = ( new HierarchicalKind("chat.attach.text"));
|
|
308
|
-
this.providedPasteEditKinds = [this.kind];
|
|
309
|
-
this.copyMimeTypes = [];
|
|
310
|
-
this.pasteMimeTypes = [COPY_MIME_TYPES, Mimes.text];
|
|
311
|
-
}
|
|
312
|
-
async provideDocumentPasteEdits(model, ranges, dataTransfer, _context, token) {
|
|
313
|
-
if (!isChatInputModel(model.uri)) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
const text = dataTransfer.get(Mimes.text);
|
|
317
|
-
const editorData = dataTransfer.get("vscode-editor-data");
|
|
318
|
-
const additionalEditorData = dataTransfer.get(COPY_MIME_TYPES);
|
|
319
|
-
if (!text) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
const textdata = await text.asString();
|
|
323
|
-
const target = this.pasteTargetService.getTarget(model.uri);
|
|
324
|
-
if (!target) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
if (model.uri.scheme !== Schemas.sessionsChatInput) {
|
|
328
|
-
const currentContextIds = ( new Set(( target.attachments.map(attachment => attachment.id))));
|
|
329
|
-
const githubAttachments = getGitHubIssueOrPullRequestAttachments(textdata).filter(attachment => !( currentContextIds.has(attachment.id)));
|
|
330
|
-
if (githubAttachments.length) {
|
|
331
|
-
if (ranges.length !== 1) {
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
const announcement = githubAttachments.length === 1 ? ( localize(10031, "Attached {0} as context", githubAttachments[0].name)) : ( localize(10032, "Attached {0} GitHub links as context", githubAttachments.length));
|
|
335
|
-
const edit = createCustomPasteEdit(model, githubAttachments, Mimes.text, this.kind, ( localize(10033, "Paste GitHub Context")), this.pasteTargetService, {
|
|
336
|
-
insertText: textdata,
|
|
337
|
-
statusAnnouncement: announcement
|
|
338
|
-
});
|
|
339
|
-
return createEditSession(edit);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
let copiedContext;
|
|
343
|
-
if (editorData && additionalEditorData) {
|
|
344
|
-
try {
|
|
345
|
-
const metadata = JSON.parse(await editorData.asString());
|
|
346
|
-
const additionalData = JSON.parse(await additionalEditorData.asString());
|
|
347
|
-
const start = additionalData.range.startLineNumber;
|
|
348
|
-
const end = additionalData.range.endLineNumber;
|
|
349
|
-
let isWholeLine = true;
|
|
350
|
-
if (start === end) {
|
|
351
|
-
const textModel = this.modelService.getModel(URI.revive(additionalData.uri));
|
|
352
|
-
isWholeLine = !!textModel && start >= 1 && start <= textModel.getLineCount() && textModel.getLineContent(start) === textdata;
|
|
353
|
-
}
|
|
354
|
-
if (isWholeLine) {
|
|
355
|
-
copiedContext = getCopiedContext(
|
|
356
|
-
textdata,
|
|
357
|
-
URI.revive(additionalData.uri),
|
|
358
|
-
metadata.mode,
|
|
359
|
-
additionalData.range
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
} catch (error) {
|
|
363
|
-
this.logService.warn("Failed to read copied text metadata", error);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
if (token.isCancellationRequested) {
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
const hasRicherPaste = !!copiedContext || ( dataTransfer.has(CHAT_ATTACHMENT_MIME_TYPE)) || dataTransfer.matches("image/*");
|
|
370
|
-
const markdown = hasRicherPaste ? undefined : await getMeaningfulMarkdown(dataTransfer);
|
|
371
|
-
if (token.isCancellationRequested) {
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
const artifact = hasRicherPaste ? undefined : createPastedTextArtifact(textdata, target.attachments, {
|
|
375
|
-
content: markdown,
|
|
376
|
-
minLength: this.configurationService.getValue(ChatConfiguration.PasteAsAttachmentThreshold, {
|
|
377
|
-
resource: model.uri
|
|
378
|
-
})
|
|
379
|
-
});
|
|
380
|
-
if (artifact) {
|
|
381
|
-
if (ranges.length !== 1 || target.isTerminalCommandPaste(textdata, ranges[0])) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
const pasteRange = ranges[0];
|
|
385
|
-
const referenceRange = ( new Range(
|
|
386
|
-
pasteRange.startLineNumber,
|
|
387
|
-
pasteRange.startColumn,
|
|
388
|
-
pasteRange.startLineNumber,
|
|
389
|
-
pasteRange.startColumn + artifact.referenceText.length
|
|
390
|
-
));
|
|
391
|
-
const referenceOffset = model.getOffsetAt(referenceRange.getStartPosition());
|
|
392
|
-
const edit = createCustomPasteEdit(model, [{
|
|
393
|
-
...artifact.attachment,
|
|
394
|
-
range: {
|
|
395
|
-
start: referenceOffset,
|
|
396
|
-
endExclusive: referenceOffset + artifact.referenceText.length
|
|
397
|
-
}
|
|
398
|
-
}], Mimes.text, this.kind, ( localize(10034, "Pasted Text Attachment")), this.pasteTargetService, {
|
|
399
|
-
inlineReference: {
|
|
400
|
-
text: artifact.referenceText,
|
|
401
|
-
range: referenceRange
|
|
402
|
-
},
|
|
403
|
-
announcement: ( localize(10035, "Attached pasted text as {0}", artifact.attachment.name))
|
|
404
|
-
});
|
|
405
|
-
return createEditSession(edit);
|
|
406
|
-
}
|
|
407
|
-
if (!copiedContext) {
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
const currentContextIds = ( new Set(( target.attachments.map(attachment => attachment.id))));
|
|
411
|
-
if (( currentContextIds.has(copiedContext.id))) {
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
const edit = createCustomPasteEdit(model, [copiedContext], Mimes.text, this.kind, ( localize(10036, "Pasted Code Attachment")), this.pasteTargetService);
|
|
415
|
-
edit.yieldTo = [{
|
|
416
|
-
kind: HierarchicalKind.Empty.append("text", "plain")
|
|
417
|
-
}];
|
|
418
|
-
return createEditSession(edit);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
function createPastedTextArtifact(text, existingAttachments, options) {
|
|
422
|
-
const trimmed = text.trim();
|
|
423
|
-
const minLength = options?.minLength ?? pastedTextArtifactDefaultMinLength;
|
|
424
|
-
if (!trimmed || trimmed.length < minLength) {
|
|
425
|
-
return undefined;
|
|
426
|
-
}
|
|
427
|
-
let index = 1;
|
|
428
|
-
let name;
|
|
429
|
-
do {
|
|
430
|
-
name = ( localize(10037, "Pasted text #{0}", index++));
|
|
431
|
-
} while (( existingAttachments.some(attachment => attachment.name === name)));
|
|
432
|
-
const content = options?.content;
|
|
433
|
-
const value = content ?? text;
|
|
434
|
-
const lineCount = countLines(value);
|
|
435
|
-
const pastedLines = lineCount === 1 ? ( localize(10038, "1 line")) : ( localize(10039, "{0} lines", lineCount));
|
|
436
|
-
const attachment = toPasteVariableEntry(name, value, {
|
|
437
|
-
language: content ? "markdown" : "plaintext",
|
|
438
|
-
fileName: name,
|
|
439
|
-
pastedLines,
|
|
440
|
-
_meta: {
|
|
441
|
-
[ChatPasteAttachmentMetadata.TextArtifact]: true
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
return {
|
|
445
|
-
attachment,
|
|
446
|
-
referenceText: `${chatVariableLeader}attachment:${name}`
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
function countLines(value) {
|
|
450
|
-
return value.split(/\r\n|\r|\n/).length;
|
|
451
|
-
}
|
|
452
|
-
function getCopiedContext(code, file, language, range) {
|
|
453
|
-
const fileName = basename(file);
|
|
454
|
-
const start = range.startLineNumber;
|
|
455
|
-
const end = range.endLineNumber;
|
|
456
|
-
const resultText = `Copied Selection of Code: \n\n\n From the file: ${fileName} From lines ${start} to ${end} \n \`\`\`${code}\`\`\``;
|
|
457
|
-
const pastedLines = start === end ? ( localize(10040, "1 line")) : ( localize(10041, "{0} lines", end + 1 - start));
|
|
458
|
-
return {
|
|
459
|
-
kind: "paste",
|
|
460
|
-
value: resultText,
|
|
461
|
-
id: `${fileName}${start}${end}${range.startColumn}${range.endColumn}`,
|
|
462
|
-
name: `${fileName} ${pastedLines}`,
|
|
463
|
-
icon: Codicon.code,
|
|
464
|
-
pastedLines,
|
|
465
|
-
language,
|
|
466
|
-
fileName: ( file.toString()),
|
|
467
|
-
copiedFrom: {
|
|
468
|
-
uri: file,
|
|
469
|
-
range
|
|
470
|
-
},
|
|
471
|
-
code,
|
|
472
|
-
references: [{
|
|
473
|
-
reference: file,
|
|
474
|
-
kind: "reference"
|
|
475
|
-
}]
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
function createCustomPasteEdit(model, context, handledMimeType, kind, title, pasteTargetService, options) {
|
|
479
|
-
const label = context.length === 1 ? context[0].name : ( localize(10042, "{0} and {1} more", context[0].name, context.length - 1));
|
|
480
|
-
const announceImageAttachment = context.length === 1 && isImageVariableEntry(context[0]);
|
|
481
|
-
const inlineReference = context.length === 1 ? options?.inlineReference : undefined;
|
|
482
|
-
const resolveTarget = operation => {
|
|
483
|
-
const target = pasteTargetService.getTarget(model.uri);
|
|
484
|
-
if (!target) {
|
|
485
|
-
throw ( new Error(`No chat paste target found for ${operation}`));
|
|
486
|
-
}
|
|
487
|
-
return target;
|
|
488
|
-
};
|
|
489
|
-
const customEdit = {
|
|
490
|
-
resource: model.uri,
|
|
491
|
-
variable: context,
|
|
492
|
-
undo: () => {
|
|
493
|
-
resolveTarget("undo").removeAttachments(( context.map(c => c.id)));
|
|
494
|
-
},
|
|
495
|
-
redo: () => {
|
|
496
|
-
const target = resolveTarget("redo");
|
|
497
|
-
if (inlineReference) {
|
|
498
|
-
target.addInlineAttachment(context[0], inlineReference.text, inlineReference.range);
|
|
499
|
-
} else {
|
|
500
|
-
target.addAttachments(context);
|
|
501
|
-
}
|
|
502
|
-
if (options?.announcement) {
|
|
503
|
-
alert(options.announcement);
|
|
504
|
-
} else if (options?.statusAnnouncement) {
|
|
505
|
-
status(options.statusAnnouncement);
|
|
506
|
-
} else if (announceImageAttachment) {
|
|
507
|
-
alert(( localize(10043, "Attached image")));
|
|
508
|
-
}
|
|
509
|
-
},
|
|
510
|
-
metadata: {
|
|
511
|
-
needsConfirmation: false,
|
|
512
|
-
label
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
return {
|
|
516
|
-
insertText: options?.inlineReference ? `${options.inlineReference.text} ` : options?.insertText ?? "",
|
|
517
|
-
title,
|
|
518
|
-
kind,
|
|
519
|
-
handledMimeType,
|
|
520
|
-
additionalEdit: {
|
|
521
|
-
edits: [customEdit]
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
function createEditSession(edit) {
|
|
526
|
-
return {
|
|
527
|
-
edits: [edit],
|
|
528
|
-
dispose: () => {}
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
const identifierPattern = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
532
|
-
const symbolCacheMaxSize = 3;
|
|
533
|
-
const symbolReferenceCache = [];
|
|
534
|
-
function getSymbolReferenceCacheKey(uri, range, text) {
|
|
535
|
-
return `${( uri.toString())}|${range.startLineNumber}:${range.startColumn}-${range.endLineNumber}:${range.endColumn}|${text}`;
|
|
536
|
-
}
|
|
537
|
-
async function getCachedSymbolReference(uri, range, text) {
|
|
538
|
-
const key = getSymbolReferenceCacheKey(uri, range, text);
|
|
539
|
-
return symbolReferenceCache.find(e => e.key === key)?.promise;
|
|
540
|
-
}
|
|
541
|
-
function cacheSymbolReference(uri, range, text, valuePromise) {
|
|
542
|
-
const entry = {
|
|
543
|
-
key: getSymbolReferenceCacheKey(uri, range, text),
|
|
544
|
-
promise: valuePromise
|
|
545
|
-
};
|
|
546
|
-
symbolReferenceCache.unshift(entry);
|
|
547
|
-
while (symbolReferenceCache.length > symbolCacheMaxSize) {
|
|
548
|
-
symbolReferenceCache.pop();
|
|
549
|
-
}
|
|
550
|
-
valuePromise.catch(() => {
|
|
551
|
-
const i = symbolReferenceCache.indexOf(entry);
|
|
552
|
-
if (i !== -1) {
|
|
553
|
-
symbolReferenceCache.splice(i, 1);
|
|
554
|
-
}
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
async function resolveSymbolReference(
|
|
558
|
-
modelService,
|
|
559
|
-
languageFeaturesService,
|
|
560
|
-
outlineModelService,
|
|
561
|
-
sourceUri,
|
|
562
|
-
sourceRange,
|
|
563
|
-
pastedText,
|
|
564
|
-
token
|
|
565
|
-
) {
|
|
566
|
-
const sourceModel = modelService.getModel(sourceUri);
|
|
567
|
-
if (!sourceModel) {
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
const sourcePosition = ( new Position(sourceRange.startLineNumber, sourceRange.startColumn));
|
|
571
|
-
const definitions = await getDefinitionsAtPosition(
|
|
572
|
-
languageFeaturesService.definitionProvider,
|
|
573
|
-
sourceModel,
|
|
574
|
-
sourcePosition,
|
|
575
|
-
false,
|
|
576
|
-
token
|
|
577
|
-
);
|
|
578
|
-
if (token.isCancellationRequested || !definitions.length) {
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
const def = definitions[0];
|
|
582
|
-
const defRange = def.targetSelectionRange ?? def.range;
|
|
583
|
-
const defLocation = {
|
|
584
|
-
uri: def.uri,
|
|
585
|
-
range: defRange
|
|
586
|
-
};
|
|
587
|
-
let icon = Codicon.symbolProperty;
|
|
588
|
-
const defModel = modelService.getModel(def.uri);
|
|
589
|
-
if (defModel) {
|
|
590
|
-
try {
|
|
591
|
-
const outline = await outlineModelService.getOrCreate(defModel, token);
|
|
592
|
-
if (!token.isCancellationRequested) {
|
|
593
|
-
const element = outline.getItemEnclosingPosition({
|
|
594
|
-
lineNumber: defRange.startLineNumber,
|
|
595
|
-
column: defRange.startColumn
|
|
596
|
-
});
|
|
597
|
-
if (element) {
|
|
598
|
-
icon = SymbolKinds.toIcon(element.symbol.kind);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
} catch {}
|
|
602
|
-
}
|
|
603
|
-
if (token.isCancellationRequested) {
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
return {
|
|
607
|
-
id: `vscode.symbol/${JSON.stringify(defLocation)}`,
|
|
608
|
-
fullName: pastedText,
|
|
609
|
-
data: defLocation,
|
|
610
|
-
icon
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
let PasteSymbolProvider = class PasteSymbolProvider {
|
|
614
|
-
constructor(
|
|
615
|
-
pasteTargetService,
|
|
616
|
-
modelService,
|
|
617
|
-
languageFeaturesService,
|
|
618
|
-
outlineModelService
|
|
619
|
-
) {
|
|
620
|
-
this.pasteTargetService = pasteTargetService;
|
|
621
|
-
this.modelService = modelService;
|
|
622
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
623
|
-
this.outlineModelService = outlineModelService;
|
|
624
|
-
this.kind = ( new HierarchicalKind("chat.attach.symbol"));
|
|
625
|
-
this.providedPasteEditKinds = [this.kind];
|
|
626
|
-
this.copyMimeTypes = [];
|
|
627
|
-
this.pasteMimeTypes = [COPY_MIME_TYPES];
|
|
628
|
-
}
|
|
629
|
-
async provideDocumentPasteEdits(model, ranges, dataTransfer, _context, token) {
|
|
630
|
-
if (!isChatInputModel(model.uri)) {
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
const text = dataTransfer.get(Mimes.text);
|
|
634
|
-
const additionalEditorData = dataTransfer.get(COPY_MIME_TYPES);
|
|
635
|
-
if (!text || !additionalEditorData) {
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
const pastedText = await text.asString();
|
|
639
|
-
if (!identifierPattern.test(pastedText)) {
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
let additionalData;
|
|
643
|
-
try {
|
|
644
|
-
additionalData = JSON.parse(await additionalEditorData.asString());
|
|
645
|
-
} catch {
|
|
646
|
-
return;
|
|
647
|
-
}
|
|
648
|
-
const sourceUri = URI.revive(additionalData.uri);
|
|
649
|
-
const sourceRange = additionalData.range;
|
|
650
|
-
if (!this.pasteTargetService.getTarget(model.uri)) {
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
const cached = await getCachedSymbolReference(sourceUri, sourceRange, pastedText);
|
|
654
|
-
let resolved = cached;
|
|
655
|
-
if (!resolved) {
|
|
656
|
-
resolved = await resolveSymbolReference(
|
|
657
|
-
this.modelService,
|
|
658
|
-
this.languageFeaturesService,
|
|
659
|
-
this.outlineModelService,
|
|
660
|
-
sourceUri,
|
|
661
|
-
sourceRange,
|
|
662
|
-
pastedText,
|
|
663
|
-
token
|
|
664
|
-
);
|
|
665
|
-
}
|
|
666
|
-
if (!resolved) {
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
if (token.isCancellationRequested) {
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
const symText = `${chatVariableLeader}sym:${pastedText}`;
|
|
673
|
-
const pasteRange = ranges[0];
|
|
674
|
-
const insertText = `${symText} `;
|
|
675
|
-
const refRange = {
|
|
676
|
-
startLineNumber: pasteRange.startLineNumber,
|
|
677
|
-
startColumn: pasteRange.startColumn,
|
|
678
|
-
endLineNumber: pasteRange.startLineNumber,
|
|
679
|
-
endColumn: pasteRange.startColumn + symText.length
|
|
680
|
-
};
|
|
681
|
-
const dynamicRef = {
|
|
682
|
-
id: resolved.id,
|
|
683
|
-
fullName: resolved.fullName,
|
|
684
|
-
range: refRange,
|
|
685
|
-
data: resolved.data,
|
|
686
|
-
icon: resolved.icon
|
|
687
|
-
};
|
|
688
|
-
const edit = {
|
|
689
|
-
insertText,
|
|
690
|
-
title: ( localize(10044, "Pasted Symbol Reference")),
|
|
691
|
-
kind: this.kind,
|
|
692
|
-
handledMimeType: COPY_MIME_TYPES,
|
|
693
|
-
additionalEdit: {
|
|
694
|
-
edits: [{
|
|
695
|
-
resource: model.uri,
|
|
696
|
-
redo: () => {
|
|
697
|
-
this.pasteTargetService.getTarget(model.uri)?.addInlineReference(dynamicRef);
|
|
698
|
-
},
|
|
699
|
-
undo: () => {}
|
|
700
|
-
}]
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
edit.yieldTo = [{
|
|
704
|
-
kind: ( new HierarchicalKind("chat.attach.text"))
|
|
705
|
-
}];
|
|
706
|
-
return createEditSession(edit);
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
PasteSymbolProvider = ( __decorate([( __param(0, IChatPasteTargetService)), ( __param(1, IModelService)), ( __param(2, ILanguageFeaturesService)), ( __param(3, IOutlineModelService))], PasteSymbolProvider));
|
|
710
|
-
class PasteHtmlProvider {
|
|
711
|
-
constructor() {
|
|
712
|
-
this.kind = ( new HierarchicalKind("chat.paste.html"));
|
|
713
|
-
this.providedPasteEditKinds = [this.kind];
|
|
714
|
-
this.copyMimeTypes = [];
|
|
715
|
-
this.pasteMimeTypes = [Mimes.html];
|
|
716
|
-
}
|
|
717
|
-
async provideDocumentPasteEdits(model, _ranges, dataTransfer, context, token) {
|
|
718
|
-
if (!isChatInputModel(model.uri)) {
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
if (context.triggerKind !== DocumentPasteTriggerKind.Automatic) {
|
|
722
|
-
return;
|
|
723
|
-
}
|
|
724
|
-
const entry = dataTransfer.get(Mimes.html);
|
|
725
|
-
const htmlText = await entry?.asString();
|
|
726
|
-
if (!htmlText || token.isCancellationRequested) {
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
if (!isMeaningfulHtml(htmlText)) {
|
|
730
|
-
return;
|
|
731
|
-
}
|
|
732
|
-
const markdown = convertHtmlToMarkdown(htmlText);
|
|
733
|
-
if (!markdown) {
|
|
734
|
-
return;
|
|
735
|
-
}
|
|
736
|
-
return createEditSession({
|
|
737
|
-
insertText: markdown,
|
|
738
|
-
title: ( localize(10045, "Paste as Markdown")),
|
|
739
|
-
kind: this.kind,
|
|
740
|
-
handledMimeType: Mimes.html,
|
|
741
|
-
yieldTo: [{
|
|
742
|
-
kind: ( new HierarchicalKind("chat.attach.text"))
|
|
743
|
-
}, {
|
|
744
|
-
kind: ( new HierarchicalKind("chat.attach.image"))
|
|
745
|
-
}]
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
async function getMeaningfulMarkdown(dataTransfer) {
|
|
750
|
-
const htmlText = await dataTransfer.get(Mimes.html)?.asString();
|
|
751
|
-
if (!htmlText || !isMeaningfulHtml(htmlText)) {
|
|
752
|
-
return undefined;
|
|
753
|
-
}
|
|
754
|
-
return convertHtmlToMarkdown(htmlText) || undefined;
|
|
755
|
-
}
|
|
756
|
-
function isMeaningfulHtml(value) {
|
|
757
|
-
return /<(a|strong|b|em|i|h[1-6]|code|pre|ul|ol|li|blockquote|del|s|strike|img|hr)\b/i.test(value);
|
|
758
|
-
}
|
|
759
|
-
let ChatPasteProvidersFeature = class ChatPasteProvidersFeature extends Disposable {
|
|
760
|
-
constructor(
|
|
761
|
-
instaService,
|
|
762
|
-
languageFeaturesService,
|
|
763
|
-
pasteTargetService,
|
|
764
|
-
extensionService,
|
|
765
|
-
fileService,
|
|
766
|
-
modelService,
|
|
767
|
-
environmentService,
|
|
768
|
-
logService,
|
|
769
|
-
configurationService
|
|
770
|
-
) {
|
|
771
|
-
super();
|
|
772
|
-
const chatInputProviders = [instaService.createInstance(CopyAttachmentsProvider), ( new PasteImageProvider(
|
|
773
|
-
pasteTargetService,
|
|
774
|
-
extensionService,
|
|
775
|
-
fileService,
|
|
776
|
-
environmentService,
|
|
777
|
-
logService
|
|
778
|
-
)), ( new PasteTextProvider(pasteTargetService, modelService, logService, configurationService)), ( new PasteHtmlProvider())];
|
|
779
|
-
for (const scheme of chatInputSchemes) {
|
|
780
|
-
for (const provider of chatInputProviders) {
|
|
781
|
-
this._register(languageFeaturesService.documentPasteEditProvider.register({
|
|
782
|
-
scheme,
|
|
783
|
-
pattern: "*",
|
|
784
|
-
hasAccessToAllModels: true
|
|
785
|
-
}, provider));
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
this._register(languageFeaturesService.documentPasteEditProvider.register({
|
|
789
|
-
scheme: Schemas.vscodeChatInput,
|
|
790
|
-
pattern: "*",
|
|
791
|
-
hasAccessToAllModels: true
|
|
792
|
-
}, instaService.createInstance(PasteSymbolProvider)));
|
|
793
|
-
this._register(
|
|
794
|
-
languageFeaturesService.documentPasteEditProvider.register("*", instaService.createInstance(CopyTextProvider))
|
|
795
|
-
);
|
|
796
|
-
}
|
|
797
|
-
};
|
|
798
|
-
ChatPasteProvidersFeature = ( __decorate([( __param(0, IInstantiationService)), ( __param(1, ILanguageFeaturesService)), ( __param(2, IChatPasteTargetService)), ( __param(3, IExtensionService)), ( __param(4, IFileService)), ( __param(5, IModelService)), ( __param(6, IEnvironmentService)), ( __param(7, ILogService)), ( __param(8, IConfigurationService))], ChatPasteProvidersFeature));
|
|
799
|
-
|
|
800
|
-
export { CHAT_ATTACHMENT_MIME_TYPE, ChatPasteProvidersFeature, CopyTextProvider, PasteImageProvider, PasteTextProvider, createPastedTextArtifact, getGitHubIssueOrPullRequestAttachments, isImage, pastedTextArtifactDefaultMinLength };
|