Skip to content

Support multiple files in working copy file service #98309

Closed
@DanTup

Description

@DanTup

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).

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalityfile-ioFile I/Ohelp wantedIssues identified as good community contribution opportunitiesinsiders-releasedPatch has been released in VS Code Insiderson-release-notesIssue/pull request mentioned in release noteson-testplanverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions