-
Notifications
You must be signed in to change notification settings - Fork 35.9k
fix off by one error for edits and checkpoints #274422
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
base: main
Are you sure you want to change the base?
Conversation
| // Restore the snapshot to what it was before the request(s) that we deleted | ||
| const snapshotRequestId = chatRequests[itemIndex].id; | ||
| await session.restoreSnapshot(snapshotRequestId, undefined); | ||
| if (itemIndex < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this tested somewhere? If so, it'd be nice to add tests.
| // Restore the snapshot to what it was before the request(s) that we deleted | ||
| const snapshotRequestId = chatRequests[itemIndex].id; | ||
| await session.restoreSnapshot(snapshotRequestId, undefined); | ||
| if (itemIndex < 0 && widget?.viewModel?.sessionResource) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the logic for restoring snapshots in chat editing actions. The change adjusts the index calculation to point to the request before the target request (by subtracting 1 from the findIndex result), and adds special handling for the edge case where this results in a negative index (indicating the first request is being undone).
Key Changes:
- Modified index calculation to subtract 1 from
findIndexresult - Added conditional logic to handle the case when undoing the first request (itemIndex < 0)
- Applied same pattern across both
chatEditingActions.tsandchatExecuteActions.ts
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts | Updates restoreSnapshotWithConfirmation function to adjust index calculation and handle first-request edge case |
| src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts | Updates SubmitAction.run method with same index adjustment and edge case handling |
fix #274084
cc @connor4312 ref #273822