-
Notifications
You must be signed in to change notification settings - Fork 731
feat(amazonq): auto-reject edit suggestions when cursor moves >25 lines away #7868
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
Changes from all commits
91265fe
266711e
1c2dee3
f1c443e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ import { EditSuggestionState } from '../editSuggestionState' | |
| import type { AmazonQInlineCompletionItemProvider } from '../completion' | ||
| import { vsCodeState } from 'aws-core-vscode/codewhisperer' | ||
|
|
||
| const autoRejectEditCursorDistance = 25 | ||
|
|
||
| export class EditDecorationManager { | ||
| private imageDecorationType: vscode.TextEditorDecorationType | ||
| private removedCodeDecorationType: vscode.TextEditorDecorationType | ||
|
|
@@ -346,6 +348,19 @@ export async function displaySvgDecoration( | |
| void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit') | ||
| } | ||
| }) | ||
| const cursorChangeListener = vscode.window.onDidChangeTextEditorSelection((e) => { | ||
| if (!EditSuggestionState.isEditSuggestionActive()) { | ||
| return | ||
| } | ||
| if (e.textEditor !== editor) { | ||
| return | ||
| } | ||
| const currentPosition = e.selections[0].active | ||
| const distance = Math.abs(currentPosition.line - startLine) | ||
| if (distance > autoRejectEditCursorDistance) { | ||
| void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit') | ||
| } | ||
| }) | ||
| await decorationManager.displayEditSuggestion( | ||
| editor, | ||
| svgImage, | ||
|
|
@@ -371,6 +386,7 @@ export async function displaySvgDecoration( | |
|
|
||
| await decorationManager.clearDecorations(editor) | ||
| documentChangeListener.dispose() | ||
| cursorChangeListener.dispose() | ||
| const params: LogInlineCompletionSessionResultsParams = { | ||
| sessionId: session.sessionId, | ||
| completionSessionResult: { | ||
|
|
@@ -405,6 +421,7 @@ export async function displaySvgDecoration( | |
| getLogger().info('Edit suggestion rejected') | ||
| await decorationManager.clearDecorations(editor) | ||
| documentChangeListener.dispose() | ||
| cursorChangeListener.dispose() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to add this method for reject case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, both accept and reject code paths represent the end of the suggestion lifecycle, so both must dispose of the listener to prevent memory leaks and ensure the listener doesn't continue running after the suggestion is already handled. |
||
| const params: LogInlineCompletionSessionResultsParams = { | ||
| sessionId: session.sessionId, | ||
| completionSessionResult: { | ||
|
|
||
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.
can you also add a screenshot of your testing?
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.
Shared video with group