Skip to content

Commit 290210f

Browse files
authored
Allow tree to specify 'files' as drop type (microsoft#153751)
For microsoft#153404 (comment) This special type indicates that the tree wants to recieve any type of file that is dropped. This matches how the dom drop apis work
1 parent 257bb1a commit 290210f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/vs/workbench/browser/parts/views/treeView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ export class CustomTreeViewDragAndDrop implements ITreeDragAndDrop<ITreeItem> {
14991499

15001500
const outDataTransfer = new VSDataTransfer();
15011501
for (const [type, item] of originalDataTransfer.entries()) {
1502-
if (type === this.treeMimeType || dndController.dropMimeTypes.indexOf(type) >= 0) {
1502+
if (type === this.treeMimeType || dndController.dropMimeTypes.includes(type) || (item.asFile() && dndController.dropMimeTypes.includes(DataTransfers.FILES.toLowerCase()))) {
15031503
outDataTransfer.append(type, item);
15041504
if (type === this.treeMimeType) {
15051505
try {

src/vscode-dts/vscode.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10166,6 +10166,8 @@ declare module 'vscode' {
1016610166
* This includes drops from within the same tree.
1016710167
* The mime type of a tree is recommended to be of the format `application/vnd.code.tree.<treeidlowercase>`.
1016810168
*
10169+
* Use the special `files` mime type to support all types of dropped files {@link DataTransferFile files}, regardless of the file's actual mime type.
10170+
*
1016910171
* To learn the mime type of a dragged item:
1017010172
* 1. Set up your `DragAndDropController`
1017110173
* 2. Use the Developer: Set Log Level... command to set the level to "Debug"

0 commit comments

Comments
 (0)