Repository navigation
Keep existing change annotations when WorkspaceChange wraps a WorkspaceEdit - #1918
Open
Ngo Quoc Viet (NgoQuocViet2001) wants to merge 1 commit into
Open
Ngo Quoc Viet (NgoQuocViet2001) wants to merge 1 commit into
Ngo Quoc Viet (NgoQuocViet2001) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The narrow fix addresses both reported failures, includes regression coverage, and has no identified blocking issues.
No open issues 🎉
What changed in this PR
This PR fixes WorkspaceChange wrapping an existing WorkspaceEdit so annotation labels and confirmation requirements are preserved.
Changes:
- Initialize the annotation count from the supplied map.
- Skip occupied annotation IDs when generating new ones.
- Add regression tests for preserving annotations and avoiding ID collisions.
| File | Description |
|---|---|
| types/src/test/edits.test.ts | Adds regression tests for both reported failures. |
| types/src/main.ts | Counts existing annotations and generates unused IDs. |
Review effort: Balanced
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.
new WorkspaceChange(edit)reusesedit.changeAnnotations, but the internalChangeAnnotationshelper starts with a size of 0 and an id counter of 0, so it ignores the annotations it was given:The first case occurs when nothing new is annotated through the helper after wrapping. The
editgetter then sees a size of 0 and drops the map, so the existing edits lose their labels andneedsConfirmation. This change counts the annotations passed to the constructor and makesnextId()skip ids that are already taken. A freshWorkspaceChangewithout annotations still returnschangeAnnotations: undefined.Ran:
npm run compile:typesandnpm --prefix types test: the two new tests inedits.test.tsfail on main and pass with this change (58 passing)npm --prefix types run lint: clean