Skip to content
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

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions vscode/src/autoedits/renderer/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ export class AutoEditsDefaultRendererManager implements AutoEditsRendererManager
protected async acceptActiveEdit(): Promise<void> {
const editor = vscode.window.activeTextEditor
const { activeRequest, decorator } = this
// Compute this variable before the `handleDidHideSuggestion` call which removes the active request.
const hasInlineDecorationOnly = this.hasInlineDecorationOnly()

if (
!editor ||
!activeRequest ||
Expand All @@ -281,9 +284,13 @@ export class AutoEditsDefaultRendererManager implements AutoEditsRendererManager
await this.handleDidHideSuggestion(decorator)
autoeditAnalyticsLogger.markAsAccepted(activeRequest.requestId)

await editor.edit(editBuilder => {
editBuilder.replace(activeRequest.codeToReplaceData.range, activeRequest.prediction)
})
// We rely on the native VS Code functionality for accepting inline completions items.
// There's no need to manually edit the document.
if (hasInlineDecorationOnly) {
await editor.edit(editBuilder => {
editBuilder.replace(activeRequest.codeToReplaceData.range, activeRequest.prediction)
})
}
}

protected async rejectActiveEdit(): Promise<void> {
Expand Down
Loading