mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
Use ids instead of indexes for resolving data transfer files (#160349)
When an extension needs to read a data transfer file, we were previously using the index of the item. This is unreliable as it means we have to ensure the array of data transfer items never changes order With this PR, i've switched us to use a unique `id` instead
This commit is contained in:
@@ -511,8 +511,8 @@ class DocumentPasteEditProvider {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
const vscodeRanges = ranges.map(range => typeConvert.Range.to(range));
|
||||
|
||||
const dataTransfer = typeConvert.DataTransfer.toDataTransfer(dataTransferDto, async (index) => {
|
||||
return (await this._proxy.$resolvePasteFileData(this._handle, requestId, index)).buffer;
|
||||
const dataTransfer = typeConvert.DataTransfer.toDataTransfer(dataTransferDto, async (id) => {
|
||||
return (await this._proxy.$resolvePasteFileData(this._handle, requestId, id)).buffer;
|
||||
});
|
||||
|
||||
const edit = await this._provider.provideDocumentPasteEdits(doc, vscodeRanges, dataTransfer, token);
|
||||
@@ -1794,8 +1794,8 @@ class DocumentOnDropEditAdapter {
|
||||
async provideDocumentOnDropEdits(requestId: number, uri: URI, position: IPosition, dataTransferDto: extHostProtocol.DataTransferDTO, token: CancellationToken): Promise<extHostProtocol.IDocumentOnDropEditDto | undefined> {
|
||||
const doc = this._documents.getDocument(uri);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
const dataTransfer = typeConvert.DataTransfer.toDataTransfer(dataTransferDto, async (index) => {
|
||||
return (await this._proxy.$resolveDocumentOnDropFileData(this._handle, requestId, index)).buffer;
|
||||
const dataTransfer = typeConvert.DataTransfer.toDataTransfer(dataTransferDto, async (id) => {
|
||||
return (await this._proxy.$resolveDocumentOnDropFileData(this._handle, requestId, id)).buffer;
|
||||
});
|
||||
|
||||
const edit = await this._provider.provideDocumentDropEdits(doc, pos, dataTransfer, token);
|
||||
|
||||
Reference in New Issue
Block a user