mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 16:49:06 +01:00
Allow passing in a DataTransferFile to workspace edit (#175809)
* Allow passing in a `DataTransferItem` to workspace edit Fixes #175800 Allows you to pass a file `DataTransferItem` to `WorkspaceEdit.createFile`. This lets us avoid transferring the data back and forth to the extension host, and also avoid having to base64 encode and decode it, significantly improving performance for large files * Take data transfer file instead of data transfer item
This commit is contained in:
@@ -31,8 +31,9 @@ class PasteEditProvider implements vscode.DocumentPasteEditProvider {
|
||||
}
|
||||
|
||||
for (const imageMime of supportedImageMimes) {
|
||||
const file = dataTransfer.get(imageMime)?.asFile();
|
||||
if (file) {
|
||||
const item = dataTransfer.get(imageMime);
|
||||
const file = item?.asFile();
|
||||
if (item && file) {
|
||||
const edit = await this._makeCreateImagePasteEdit(document, file, token);
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
@@ -70,7 +71,7 @@ class PasteEditProvider implements vscode.DocumentPasteEditProvider {
|
||||
|
||||
// Note that there is currently no way to undo the file creation :/
|
||||
const workspaceEdit = new vscode.WorkspaceEdit();
|
||||
workspaceEdit.createFile(uri, { contents: await file.data() });
|
||||
workspaceEdit.createFile(uri, { contents: file });
|
||||
|
||||
const pasteEdit = new vscode.DocumentPasteEdit(snippet);
|
||||
pasteEdit.additionalEdit = workspaceEdit;
|
||||
|
||||
Reference in New Issue
Block a user