mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 17:20:28 -04:00
Merge from vscode 3bd60b2ba753e7fe39b42f99184bc6c5881d3551 (#4712)
This commit is contained in:
@@ -429,6 +429,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
|
||||
|
||||
private toDispose: IDisposable[];
|
||||
private dropEnabled: boolean;
|
||||
private isCopy: boolean;
|
||||
|
||||
constructor(
|
||||
@INotificationService private notificationService: INotificationService,
|
||||
@@ -549,7 +550,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
|
||||
}
|
||||
|
||||
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<ExplorerItem> {
|
||||
}
|
||||
|
||||
onDragStart(data: IDragAndDropData, originalEvent: DragEvent): void {
|
||||
this.isCopy = (originalEvent.ctrlKey && !isMacintosh) || (originalEvent.altKey && isMacintosh);
|
||||
const items = (data as ElementsDragAndDropData<ExplorerItem>).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<ExplorerItem> {
|
||||
}
|
||||
// In-Explorer DND (Move/Copy file)
|
||||
else {
|
||||
this.handleExplorerDrop(data, target, originalEvent);
|
||||
this.handleExplorerDrop(data, target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,15 +713,14 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
private handleExplorerDrop(data: IDragAndDropData, target: ExplorerItem, originalEvent: DragEvent): Promise<void> {
|
||||
private handleExplorerDrop(data: IDragAndDropData, target: ExplorerItem): Promise<void> {
|
||||
const elementsData = (data as ElementsDragAndDropData<ExplorerItem>).elements;
|
||||
const items = distinctParents(elementsData, s => s.resource);
|
||||
const isCopy = (originalEvent.ctrlKey && !isMacintosh) || (originalEvent.altKey && isMacintosh);
|
||||
|
||||
let confirmPromise: Promise<IConfirmationResult>;
|
||||
|
||||
// Handle confirm setting
|
||||
const confirmDragAndDrop = !isCopy && this.configurationService.getValue<boolean>(FileDragAndDrop.CONFIRM_DND_SETTING_KEY);
|
||||
const confirmDragAndDrop = !this.isCopy && this.configurationService.getValue<boolean>(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?")
|
||||
@@ -747,7 +748,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user