-
Notifications
You must be signed in to change notification settings - Fork 332
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
feat(auto-edits): fix the suffix duplication on inline accept #6583
Conversation
await editor.edit(editBuilder => { | ||
editBuilder.replace(activeRequest.codeToReplaceData.range, activeRequest.prediction) | ||
}) | ||
if (this.activeRequest && this.hasInlineDecorationOnly()) { |
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.
@umpox @valerybugakov Added this condition which helps fix the issue. Seems like vscode internally replaces the text and then this event again replaces the updated text, causing the issue.
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.
Pushed a small update to precompute hasInlineDecorationOnly
before the handleDidHideSuggestion
call.
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.
TY!
The backport to
To backport this PR manually, you can either: Via the sg toolUse the sg backport -r jb-v7.8.x -p 6583 Via your terminalTo backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-jb-v7.8.x jb-v7.8.x
# Navigate to the new working tree
cd .worktrees/backport-jb-v7.8.x
# Create a new branch
git switch --create backport-6583-to-jb-v7.8.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 e56f4f7f635d0a5701c725bb9b0d9396b88925a6
# Push it to GitHub
git push --set-upstream origin backport-6583-to-jb-v7.8.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-jb-v7.8.x If you encouter conflict, first resolve the conflict and stage all files, then run the commands below: git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-6583-to-jb-v7.8.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-jb-v7.8.x
Once the pull request has been created, please ensure the following:
|
…n on inline accept (#6590) ## Context For the `auto-edits` feature, the suffix is duplicated on every inline suffix. This is a regression from the current pre-release, and this is affecting almost every inline completion suggestion spanning multiple lines. This is happening because, for inline completion item acceptance: 1. First vscode internally accepts the completion and replace in editor and 2. Our custom acceptEdit replaces the replaced text from vscode [Linear Issue Link](https://linear.app/sourcegraph/issue/CODY-4652/fix-duplicate-code-inserted-when-inline-completion-accepted) **Before** Suggestion: <img width="325" alt="image" src="https://github.com/user-attachments/assets/76835430-f6aa-4b03-9407-bce25e28badf" /> On Acceptance: <img width="312" alt="image" src="https://github.com/user-attachments/assets/1c18168a-dc8f-44af-9c09-5ae8e401e41f" /> **After** Replaces the correct suggestion without suffix duplication: <img width="279" alt="image" src="https://github.com/user-attachments/assets/b8505644-5686-4171-8351-8d054bf0946c" /> ## Test plan Inline Examples from the [cody-chat-eval repo ](https://github.com/sourcegraph/cody-chat-eval/blob/main/code-matching-eval/edits_experiments/examples/renderer-testing-examples/suffix-duplication-issue.ts) <br> Backport e56f4f7 from #6583 Co-authored-by: Hitesh Sagtani <[email protected]>
Adds the test case for the two issues we faced: 1. Tab not working when conflicted with edit command decorations. [Resolves comment](#6581 (comment)) - [test cases for PR](#6581) 2. Suffix getting duplicated because in addition to inline acceptance, we were modifying the document again on accept - [[test case for PR](#6583)] ## Test plan Added test case
Context
For the
auto-edits
feature, the suffix is duplicated on every inline suffix. This is a regression from the current pre-release, and this is affecting almost every inline completion suggestion spanning multiple lines. This is happening because, for inline completion item acceptance:Linear Issue Link
Before
Suggestion:
On Acceptance:
After
Replaces the correct suggestion without suffix duplication:
Test plan
Inline Examples from the cody-chat-eval repo