Skip to content
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

Should send a single FileWillRenameEvent instead of separate events when moving multiple files at once #111867

Closed
testforstephen opened this issue Dec 4, 2020 · 21 comments
Assignees
Labels
debt Code quality issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded workspace-edit
Milestone

Comments

@testforstephen
Copy link

Currently, if I drag and drop multiple files to a new location at once, the VS Code File Event API workspace.onWillRenameFiles will send a separate FileWillRenameEvent for each file to be moved. If i choose to use FileWillRenameEvent.waitUtil() to return the refactored edit, that means each event will return a separate edit and the client will call the applyEdit operation multiple times. This is inconvenient for undo operation.

It's better to send a single FileWillRenameEvent instead of separate events when moving multiple files at once.

@jrieken
Copy link
Member

jrieken commented Dec 4, 2020

Very good find. We have this loop which goes over all resource edits and instead of the going one-by-one it should create buckets of equal operation types (likely without changing the order) and then apply a bucket at once

@jrieken
Copy link
Member

jrieken commented Dec 11, 2020

This needs support from the working copy service. For instance, delete only supports a single options bag but multiple resources. Today, we ask the file- & config-service for a single resource whether to use trash or not but I don't see how that's possible with different resources from potentially different schemes/providers. There are similar issues with copying multiple files but using different overwrite settings etc

@bpasero
Copy link
Member

bpasero commented Dec 11, 2020

@isidorn let me know if you are interested in a PR to change the working copy file service to support options per resource. I think the support for bulk came in later (via a PR) but we should have also allowed the options to be specified per resource. Instead of adding another options array I would probably just allow to pass in resource and options in one object.

Overall this is not a big change glancing at the existing code, shouldn't be hard.

@isidorn
Copy link
Contributor

isidorn commented Dec 11, 2020

@bpasero yeah, I can look into a PR. Will do it early next week.

@jrieken
Copy link
Member

jrieken commented Dec 16, 2020

@isidorn can you ping when you have done that PR

@isidorn
Copy link
Contributor

isidorn commented Dec 17, 2020

Will do, started to look into it now...

@isidorn
Copy link
Contributor

isidorn commented Dec 17, 2020

@jrieken @bpasero Created PR #112760

@bpasero
Copy link
Member

bpasero commented Jan 4, 2021

Is this done?

@jrieken
Copy link
Member

jrieken commented Jan 4, 2021

Nope

jrieken added a commit that referenced this issue Jan 6, 2021
@jrieken
Copy link
Member

jrieken commented Jan 6, 2021

@isidorn I am confused why creating doesn't support multiple resources at once while everything else does. Like, undoing a "multi delete" is now separate create operations

@isidorn
Copy link
Contributor

isidorn commented Jan 6, 2021

@jrieken originally I did the create to support multiple resources, however after discussion with @bpasero I reverted back to only support a single operation.

I can move back to multi operation support. Though let's see if @bpasero is fine with that

@bpasero
Copy link
Member

bpasero commented Jan 6, 2021

I have no feelings either way is fine for me.

@isidorn
Copy link
Contributor

isidorn commented Jan 6, 2021

Okey so I will bring back the support for multi create. I will push directly to master and ping you Ben on the commit.

@isidorn
Copy link
Contributor

isidorn commented Jan 6, 2021

I have just pushed a commit that tackles this d51e1fa
I did not adopt this fully in the bulkFileEdits since I thought you are wokring on it @jrieken Let me know if you would like me to look into that

@jrieken
Copy link
Member

jrieken commented Jan 6, 2021

Thanks @isidorn. I am almost done with the adoption

@bpasero
Copy link
Member

bpasero commented Jan 6, 2021

@isidorn checked out the change, it seems that the API now allows for multiple create operations, but within, we are not wiring this in properly (I think that was my initial feedback too that made us go back to supporting just 1 operation).

Specifically, shouldn't we use the array of things to create when passing on to the participants and eventing:

await this.runFileOperationParticipants([{ target: operation.resource }], FileOperation.CREATE, undoInfo, token);

const event = { correlationId: this.correlationIds++, operation: FileOperation.CREATE, files: [{ target: operation.resource }] };

Maybe @jrieken can clarify if this kind of change is still needed or not.

@jrieken
Copy link
Member

jrieken commented Jan 6, 2021

Yes - the event should be fired for many resources. There is a skipped/failing test here:

test('Should send a single FileWillRenameEvent instead of separate events when moving multiple files at once#111867', async function () {
this.skip();

@isidorn
Copy link
Contributor

isidorn commented Jan 6, 2021

@bpasero thanks for the feedback, I have created this PR #113919 to tackle it

jrieken added a commit that referenced this issue Jan 7, 2021
@jrieken
Copy link
Member

jrieken commented Jan 7, 2021

Closing. This is now done. @testforstephen please try this out with next insiders. Thanks

@jrieken jrieken closed this as completed Jan 7, 2021
@testforstephen
Copy link
Author

I have played with the insider on 2021-01-08, moving multiple files will be grouped to one FileWillRenameEvent, which works well for me. Thanks for this great fix.

@isidorn
Copy link
Contributor

isidorn commented Jan 11, 2021

Thanks a lot for trying it out. Adding verified label based on your comment.

@isidorn isidorn added verification-needed Verification of issue is requested verified Verification succeeded labels Jan 11, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Feb 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded workspace-edit
Projects
None yet
Development

No branches or pull requests

4 participants