Skip to content

Commit 7086bb8

Browse files
committed
multiple selection drag and drop inside workbench
1 parent fca6ee5 commit 7086bb8

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

src/vs/base/browser/dnd.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export const DataTransfers = {
4949
*/
5050
URL: 'URL',
5151

52+
/**
53+
* Application specific resource transfer type when multiple resources are being dragged.
54+
*/
55+
URLS: 'URLS',
56+
5257
/**
5358
* Browser specific transfer type to download.
5459
*/
@@ -58,4 +63,4 @@ export const DataTransfers = {
5863
* Typicaly transfer type for copy/paste transfers.
5964
*/
6065
TEXT: 'text/plain'
61-
};
66+
};

src/vs/workbench/browser/editor.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,19 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): (IDragge
241241

242242
// Data Transfer: URL
243243
else {
244-
const rawURLData = e.dataTransfer.getData(DataTransfers.URL);
245-
if (rawURLData) {
246-
try {
247-
resources.push({ resource: URI.parse(rawURLData), isExternal: false });
248-
} catch (error) {
249-
// Invalid URI
244+
try {
245+
const rawURLsData = e.dataTransfer.getData(DataTransfers.URLS);
246+
if (rawURLsData) {
247+
const uriStrArray: string[] = JSON.parse(rawURLsData);
248+
resources.push(...uriStrArray.map(uriStr => ({ resource: URI.parse(uriStr), isExternal: false })));
249+
} else {
250+
const rawURLData = e.dataTransfer.getData(DataTransfers.URL);
251+
if (rawURLData) {
252+
resources.push({ resource: URI.parse(rawURLData), isExternal: false });
253+
}
250254
}
255+
} catch (error) {
256+
// Invalid URI
251257
}
252258
}
253259
}
@@ -268,4 +274,4 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): (IDragge
268274
}
269275

270276
return resources;
271-
}
277+
}

src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,13 +726,14 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop {
726726
});
727727

728728
// Apply some datatransfer types to allow for dragging the element outside of the application
729-
// TODO@Isidor check this
730729
if (sources.length === 1) {
731730
if (!sources[0].isDirectory) {
732731
originalEvent.dataTransfer.setData(DataTransfers.DOWNLOAD_URL, [MIME_BINARY, sources[0].name, sources[0].resource.toString()].join(':'));
733732
}
734733

735734
originalEvent.dataTransfer.setData(DataTransfers.TEXT, getPathLabel(sources[0].resource));
735+
} else {
736+
originalEvent.dataTransfer.setData(DataTransfers.URLS, JSON.stringify(sources.map(s => s.resource.toString())));
736737
}
737738
}
738739
}

0 commit comments

Comments
 (0)