-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Description
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:
vscode/src/vs/workbench/api/common/extHostFileSystemEventService.ts
Lines 219 to 228 in 926fc23
| 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.
The code for that repro is available here:
https://github.com/DanTup/vscode-repro-will-rename-files (extension.ts).
