mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-14 20:34:30 +01:00
Allow multiple entries with the same mimetype in dataTransfer (#150425)
Currently our data transfer implementation only allows a single entry of each mimeType. There can only be a single `image/gif` file for example. However this doesn't match how the DOM apis work. If you drop multiple gifs into VS Code for example, the DataTransfer you get contains entries for each of the gifs. This change allows us to also support DataTransfers that have multiple entries with the same mime type. Just like with the DOM, we support constructing these duplicate mime data transfers internally, but do not allow extensions to create them As part of this change, I've also made a few clean ups: - Add helpers for creating dataTransfer items - Clarify when adding a data transfer item should `append` or `replace` - Adopt some helper functions in a few more places
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { VSDataTransfer } from 'vs/base/common/dataTransfer';
|
||||
import { createStringDataTransferItem, VSDataTransfer } from 'vs/base/common/dataTransfer';
|
||||
import { CancellationError } from 'vs/base/common/errors';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { combinedDisposable, Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
@@ -385,7 +385,7 @@ export class MainThreadLanguageFeatures extends Disposable implements MainThread
|
||||
|
||||
const dataTransferOut = new VSDataTransfer();
|
||||
result.items.forEach(([type, item]) => {
|
||||
dataTransferOut.setString(type, item.asString);
|
||||
dataTransferOut.replace(type, createStringDataTransferItem(item.asString));
|
||||
});
|
||||
return dataTransferOut;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user