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

Support multiple files in working copy file service #98309

Closed
DanTup opened this issue May 21, 2020 · 8 comments · Fixed by #98988
Closed

Support multiple files in working copy file service #98309

DanTup opened this issue May 21, 2020 · 8 comments · Fixed by #98988
Assignees
Labels
feature-request Request for new features or functionality file-io File I/O help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders on-release-notes Issue/pull request mentioned in release notes on-testplan verified Verification succeeded
Milestone

Comments

@DanTup
Copy link
Contributor

DanTup commented May 21, 2020

When dragging multiple files in the explorer, the onWillRenameFiles event is fired multiple times concurrently with a single file per-call - even though the API supports an array:

await this._fireWillEvent(this._onWillRenameFile, { files: [{ oldUri: URI.revive(source!), newUri: URI.revive(target) }] }, timeout, token);

This means an extension will produce multiple edits for a single operation if there are multiple files moved - though it looks like VS Code merges them together:

if (edits.length > 0) {
// flatten all WorkspaceEdits collected via waitUntil-call
// and apply them in one go.
const allEdits = new Array<Array<IWorkspaceFileEditDto | IWorkspaceTextEditDto>>();
for (let edit of edits) {
let { edits } = typeConverter.WorkspaceEdit.from(edit, this._extHostDocumentsAndEditors);
allEdits.push(edits);
}
return this._mainThreadTextEditors.$tryApplyWorkspaceEdit({ edits: flatten(allEdits) });
}

However, this fails if two of the edits modified the same file with "(file) has changed in the meantime".

Here's a gif showing individual file moves correctly updating the file on the right. However if I moved them both at the same time, only one edit is applied and the other one fails.

multi_rename_fails2

The code for that repro is available here:

https://github.com/DanTup/vscode-repro-will-rename-files (extension.ts).

@jrieken
Copy link
Member

jrieken commented May 26, 2020

@bpasero, @isidorn Not sure if the working-copy service still needs support for this or if the explorer didn't adopt this yet

@bpasero
Copy link
Member

bpasero commented May 26, 2020

@jrieken I was not aware there is support for an array of resources, e.g. when I look at $onWillRunFileOperation and $onDidRunFileOperation I can only pass in a single resource. But it would probably be easy enough to support an array here given the ext host side supports an array for the event.

This needs:

  • support on the working copy file service to do operations on multiple resources
  • adoption in places where we want to support this (e.g. explorer)

Setting help wanted if someone wants to do this, shouldn't be too complicated.

@bpasero bpasero added feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities file-io File I/O labels May 26, 2020
@bpasero bpasero added this to the Backlog milestone May 26, 2020
@bpasero bpasero changed the title onWillRenameFiles fails when moving multiple files because of multiple concurrent edits Support multiple files in working copy file service May 26, 2020
@pfongkye
Copy link
Contributor

Hi @bpasero
I would like to work on this issue if nobody else is.

@bpasero
Copy link
Member

bpasero commented May 30, 2020

Yes, go for it 👍

@bpasero bpasero modified the milestones: Backlog, June 2020 Jun 10, 2020
@isidorn isidorn removed their assignment Jun 12, 2020
@isidorn
Copy link
Contributor

isidorn commented Jun 12, 2020

@bpasero I see you are reviewing this. Feel free to assign me back if you need some help.

bpasero added a commit to pfongkye/vscode that referenced this issue Jun 24, 2020
@bpasero
Copy link
Member

bpasero commented Jun 26, 2020

@DanTup can you please verify your original issue is resolved with your test extension?

@bpasero bpasero added the on-release-notes Issue/pull request mentioned in release notes label Jun 26, 2020
@DanTup
Copy link
Contributor Author

DanTup commented Jun 29, 2020

Yes, this works! Thank you @pfongkye @bpasero! 😀

@isidorn isidorn added the verified Verification succeeded label Jun 29, 2020
@pfongkye
Copy link
Contributor

Yes, this works! Thank you @pfongkye @bpasero!

Great 😃
You're welcome.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality file-io File I/O help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders on-release-notes Issue/pull request mentioned in release notes on-testplan verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@bpasero @pfongkye @DanTup @jrieken @isidorn and others