diff --git a/src/vs/workbench/api/common/extHostTreeViews.ts b/src/vs/workbench/api/common/extHostTreeViews.ts index 76ccbbd770d..6d0250d4436 100644 --- a/src/vs/workbench/api/common/extHostTreeViews.ts +++ b/src/vs/workbench/api/common/extHostTreeViews.ts @@ -149,20 +149,16 @@ export class ExtHostTreeViews implements ExtHostTreeViewsShape { private async addAdditionalTransferItems(treeDataTransfer: ITreeDataTransfer, treeView: ExtHostTreeView, sourceTreeItemHandles: string[], operationUuid?: string): Promise { const existingTransferOperation = this.treeDragAndDropService.removeDragOperationTransfer(operationUuid); - let additionalTransferItems: vscode.TreeDataTransfer | undefined; if (existingTransferOperation) { - additionalTransferItems = await existingTransferOperation; - } else if (operationUuid && treeView.handleDrag) { - const willDropPromise = treeView.handleDrag(sourceTreeItemHandles); - this.treeDragAndDropService.addDragOperationTransfer(operationUuid, willDropPromise); - additionalTransferItems = await willDropPromise; - } - if (additionalTransferItems) { - additionalTransferItems.forEach((value, key) => { + (await existingTransferOperation)?.forEach((value, key) => { if (value) { treeDataTransfer.set(key, value); } }); + } else if (operationUuid && treeView.handleDrag) { + const willDropPromise = treeView.handleDrag(sourceTreeItemHandles, treeDataTransfer); + this.treeDragAndDropService.addDragOperationTransfer(operationUuid, willDropPromise); + await willDropPromise; } return treeDataTransfer; } @@ -435,7 +431,7 @@ class ExtHostTreeView extends Disposable { } } - async handleDrag(sourceTreeItemHandles: TreeItemHandle[]): Promise { + async handleDrag(sourceTreeItemHandles: TreeItemHandle[], treeDataTransfer: ITreeDataTransfer): Promise { const extensionTreeItems: T[] = []; for (const sourceHandle of sourceTreeItemHandles) { const extensionItem = this.getExtensionElement(sourceHandle); @@ -447,7 +443,8 @@ class ExtHostTreeView extends Disposable { if (!this.dndController?.handleDrag || (extensionTreeItems.length === 0)) { return; } - return this.dndController.handleDrag(extensionTreeItems); + await this.dndController.handleDrag(extensionTreeItems, treeDataTransfer); + return treeDataTransfer; } get hasHandleDrag(): boolean { diff --git a/src/vscode-dts/vscode.proposed.treeViewDragAndDrop.d.ts b/src/vscode-dts/vscode.proposed.treeViewDragAndDrop.d.ts index 7f0cea4602b..f135fa73a8d 100644 --- a/src/vscode-dts/vscode.proposed.treeViewDragAndDrop.d.ts +++ b/src/vscode-dts/vscode.proposed.treeViewDragAndDrop.d.ts @@ -102,11 +102,10 @@ declare module 'vscode' { * When the items are dropped on **another tree item** in **the same tree**, your `TreeDataTransferItem` objects * will be preserved. See the documentation for `TreeDataTransferItem` for how best to take advantage of this. * - * The returned `TreeDataTransfer` will be merged with the original`TreeDataTransfer` for the operation. - * * @param source The source items for the drag and drop operation. + * @param treeDataTransfer The data transfer associated with this drag. */ - handleDrag?(source: T[]): Thenable; + handleDrag?(source: T[], treeDataTransfer: TreeDataTransfer): Thenable | void; /** * Called when a drag and drop action results in a drop on the tree that this `DragAndDropController` belongs too.