diff --git a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts index 631175e5693f8595bf493f7320b585361c78a6be..17dceabc6e5661a8e65c7326bb3765d6ed9cc4bd 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts @@ -429,6 +429,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { private toDispose: IDisposable[]; private dropEnabled: boolean; + private isCopy: boolean; constructor( @INotificationService private notificationService: INotificationService, @@ -549,7 +550,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { } getDragURI(element: ExplorerItem): string | null { - if (this.explorerService.isEditable(element)) { + if (this.explorerService.isEditable(element) || (!this.isCopy && element.isReadonly)) { return null; } @@ -565,6 +566,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { } onDragStart(data: IDragAndDropData, originalEvent: DragEvent): void { + this.isCopy = (originalEvent.ctrlKey && !isMacintosh) || (originalEvent.altKey && isMacintosh); const items = (data as ElementsDragAndDropData).elements; if (items && items.length && originalEvent.dataTransfer) { // Apply some datatransfer types to allow for dragging the element outside of the application @@ -597,7 +599,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { } // In-Explorer DND (Move/Copy file) else { - this.handleExplorerDrop(data, target, originalEvent); + this.handleExplorerDrop(data, target); } } @@ -712,15 +714,14 @@ export class FileDragAndDrop implements ITreeDragAndDrop { return Promise.resolve(undefined); } - private handleExplorerDrop(data: IDragAndDropData, target: ExplorerItem, originalEvent: DragEvent): Promise { + private handleExplorerDrop(data: IDragAndDropData, target: ExplorerItem): Promise { const elementsData = (data as ElementsDragAndDropData).elements; const items = distinctParents(elementsData, s => s.resource); - const isCopy = (originalEvent.ctrlKey && !isMacintosh) || (originalEvent.altKey && isMacintosh); let confirmPromise: Promise; // Handle confirm setting - const confirmDragAndDrop = !isCopy && this.configurationService.getValue(FileDragAndDrop.CONFIRM_DND_SETTING_KEY); + const confirmDragAndDrop = !this.isCopy && this.configurationService.getValue(FileDragAndDrop.CONFIRM_DND_SETTING_KEY); if (confirmDragAndDrop) { confirmPromise = this.dialogService.confirm({ message: items.length > 1 && items.every(s => s.isRoot) ? localize('confirmRootsMove', "Are you sure you want to change the order of multiple root folders in your workspace?") @@ -748,7 +749,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { return updateConfirmSettingsPromise.then(() => { if (res.confirmed) { const rootDropPromise = this.doHandleRootDrop(items.filter(s => s.isRoot), target); - return Promise.all(items.filter(s => !s.isRoot).map(source => this.doHandleExplorerDrop(source, target, isCopy)).concat(rootDropPromise)).then(() => undefined); + return Promise.all(items.filter(s => !s.isRoot).map(source => this.doHandleExplorerDrop(source, target, this.isCopy)).concat(rootDropPromise)).then(() => undefined); } return Promise.resolve(undefined);