From f0c511b372efc700c95589a31da200a9bece1ee4 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 15 Jun 2016 15:11:18 +0200 Subject: [PATCH] support in-app DND to editor area --- .../parts/editor/sideBySideEditorControl.ts | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts b/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts index cc2a70b7f06..cb688c820c4 100644 --- a/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts +++ b/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts @@ -762,20 +762,32 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti node.addEventListener(DOM.EventType.DROP, (e: DragEvent) => { DOM.EventHelper.stop(e); - // Check for native file transfer - if (e.dataTransfer && e.dataTransfer.files) { - let thepaths: string[] = []; - for (let i = 0; i < e.dataTransfer.files.length; i++) { - if (e.dataTransfer.files[i] && e.dataTransfer.files[i].path) { - thepaths.push(e.dataTransfer.files[i].path); + const droppedResources: URI[] = []; + if (e.dataTransfer.types.length > 0) { + + // Check for in-app DND + const rawData = e.dataTransfer.getData(e.dataTransfer.types[0]); + if (rawData) { + const resource = URI.parse(rawData); + if (resource.scheme === 'file' || resource.scheme === 'untitled') { + droppedResources.push(resource); } } - if (thepaths.length) { - window.focus(); // make sure this window has focus so that the open call reaches the right window! - this.openFromDrop(thepaths.map(p => URI.file(p)), e.toElement).done(null, errors.onUnexpectedError); + // Check for native file transfer + if (e.dataTransfer && e.dataTransfer.files) { + for (let i = 0; i < e.dataTransfer.files.length; i++) { + if (e.dataTransfer.files[i] && e.dataTransfer.files[i].path) { + droppedResources.push(URI.file(e.dataTransfer.files[i].path)); + } + } } } + + if (droppedResources.length) { + window.focus(); // make sure this window has focus so that the open call reaches the right window! + this.openFromDrop(droppedResources, e.toElement).done(null, errors.onUnexpectedError); + } }); }