Skip to content

Commit

Permalink
Only log supported mime types in tree dnd
Browse files Browse the repository at this point in the history
Fixes #145681
  • Loading branch information
alexr00 committed Mar 22, 2022
1 parent 58a421d commit 637af81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/vs/workbench/browser/parts/views/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1337,8 +1337,19 @@ export class CustomTreeViewDragAndDrop implements ITreeDragAndDrop<ITreeItem> {
}
}

private debugLog(originalEvent: DragEvent) {
const types = originalEvent.dataTransfer?.types.filter((_value, index) => {
return (originalEvent.dataTransfer?.items[index].kind === 'string');
});
if (types?.length) {
this.logService.debug(`TreeView dragged mime types: ${types.join(', ')}`);
} else {
this.logService.debug(`TreeView dragged with no supported mime types.`);
}
}

onDragOver(data: IDragAndDropData, targetElement: ITreeItem, targetIndex: number, originalEvent: DragEvent): boolean | ITreeDragOverReaction {
this.logService.debug(`TreeView dragged mime types: ${originalEvent.dataTransfer?.types.join(', ')}`);
this.debugLog(originalEvent);
const dndController = this.dndController;
if (!dndController || !originalEvent.dataTransfer || (dndController.dropMimeTypes.length === 0)) {
return false;
Expand Down
1 change: 1 addition & 0 deletions src/vscode-dts/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9825,6 +9825,7 @@ declare module 'vscode' {
* 1. Set up your `DragAndDropController`
* 2. Use the Developer: Set Log Level... command to set the level to "Debug"
* 3. Open the developer tools and drag the item with unknown mime type over your tree. The mime types will be logged to the developer console
* Note that only mime types of kind "string" are supported and will be logged (ex. files will not be logged).
*/
readonly dropMimeTypes: string[];

Expand Down

0 comments on commit 637af81

Please sign in to comment.