Repository navigation
Reverse undo operations and rename edits in BulkFileEdits (fixes #344765) - #344776
Open
Ayush Kr Singh (ayushkrsingh946) wants to merge 5 commits into
Open
Ayush Kr Singh (ayushkrsingh946) wants to merge 5 commits into
Ayush Kr Singh (ayushkrsingh946) wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change to undo/redo ordering of dependent file operations.
No open issues 🎉
What changed in this PR
Fixes #344765 by reversing dependent file operations during undo, preventing “target already exists” failures when a workspace edit moves a file out of a folder and then renames that folder.
Changes:
- Reverse inverse rename operations so undo respects move dependencies.
- Reverse operation groups for undo and restore their original order on redo.
- Add regression tests covering rename ordering and mixed operation groups.
| File | Description |
|---|---|
src/vs/workbench/contrib/bulkEdit/test/browser/bulkFileEdits.test.ts |
Adds undo/redo ordering tests for dependent renames and mixed groups. |
src/vs/workbench/contrib/bulkEdit/browser/bulkFileEdits.ts |
Reverses inverse renames and operation groups during undo/redo. |
Review effort: Balanced
| } | ||
|
|
||
| private async _reverse() { | ||
| this.operations.reverse(); |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes #344765
Summary
When an extension applies a
WorkspaceEditthat moves a file out of a folder and then renames the folder:Undo, the inverse operations were executed in forward order, which caused the file to be moved back first. This created the source folder directory, making the subsequent folder rename fail with "target already exists".Cause & Solution
RenameOperation.perform(),undoeswere collected and returned in forward application order. We now returnnew RenameOperation(undoes.reverse(), ...). When undoing, moves execute in reverse order; and when redoing, the inverse of the inverse is reversed again, restoring the original forward order.FileUndoRedoElement._reverse(), operations were iterated in forward order for both undo and redo. Reversingthis.operationsensures multi-group operations are undone in reverse order and restored on redo.Verification
src/vs/workbench/contrib/bulkEdit/test/browser/bulkFileEdits.test.ts:rename reverses moves order on undo and restores order on redoundo and redo reverse operation groups ordernpm run precommithygiene checks pass cleanly.npm run typecheck-clientpasses cleanly.