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:
Matt Bierner
2022-09-07 13:18:49 -07:00
committed by GitHub
parent 92626b7a60
commit f86ceb6749
8 changed files with 47 additions and 28 deletions

View File

@@ -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);