-
Notifications
You must be signed in to change notification settings - Fork 29.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable multi root DnD #45428
enable multi root DnD #45428
Conversation
@isidorn thanks will do |
@@ -817,7 +817,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop { | |||
return true; // NewStatPlaceholders can not be moved | |||
} | |||
|
|||
if (source.isRoot && (sources.length > 1 || target instanceof FileStat && !target.isRoot)) { | |||
if (source.isRoot && target instanceof FileStat && !target.isRoot) { | |||
return true; // Root folder can not be moved to a non root file stat. Do not allow root folder move when multi selection drag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment needs an update too I think
uri: folders[index].uri | ||
}); | ||
} | ||
private doHandleRootDrop(roots: FileStat[], target: FileStat | Model): TPromise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be much easier here to do something like:
- fill an array of roots that includes everything except the roots that are being dragged
- find the index where to drop to (if target is
model
, the index is the length of the array) - add the roots that are being dragged into the array at the correct location
- call workspace editing service with that array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. This simplifies a bit. This was tackled via 5564db9
for (let index = 0; index < folders.length; index++) { | ||
const data = { | ||
name: folders[index].name, | ||
uri: folders[index].uri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isidorn also careful here, you are introducing a name
property that previously might not have been there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bpasero how can I check if the name was there previously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isidorn you don't need to, just leave name
empty
Great, thanks for feedback. I feel like I have addressed all the issues -> merging |
fixes #44554
Not the nicest code but gets the job done for multi select root DnD.
@bpasero please review and let me know if you know how to simplify this. Thanks!