Skip to content

Commit d2ecf2e

Browse files
authored
fix(amazonq): skip inline completion when deleting (#5874)
* skip inline completion when deleting * detekt * use offset * separate implementation for 2024.2 and 2024.3+ * detekt * detekt
1 parent 6843c20 commit d2ecf2e

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Skip inline completion when deleting characters"
4+
}

plugins/amazonq/codewhisperer/jetbrains-community/src-242/software/aws/toolkits/jetbrains/services/codewhisperer/popup/QManualCall.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ fun getManualCallEvent(editor: Editor, isIntelliSenseAccept: Boolean): InlineCom
1919
}
2020
return InlineCompletionEvent.DirectCall(editor, editor.caretModel.currentCaret, dataContext)
2121
}
22+
23+
@Suppress("FunctionOnlyReturningConstant")
24+
fun InlineCompletionEvent.isDeletion(): Boolean = false

plugins/amazonq/codewhisperer/jetbrains-community/src-243+/software/aws/toolkits/jetbrains/services/codewhisperer/popup/QManualCall.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ fun getManualCallEvent(editor: Editor, isIntelliSenseAccept: Boolean): InlineCom
1515
val data = UserDataHolderBase().apply { this.putUserData(KEY_Q_AUTO_TRIGGER_INTELLISENSE, isIntelliSenseAccept) }
1616
return InlineCompletionEvent.ManualCall(editor, Q_INLINE_PROVIDER_ID, data)
1717
}
18+
19+
fun InlineCompletionEvent.isDeletion(): Boolean =
20+
this is InlineCompletionEvent.Backspace

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/popup/QInlineCompletionProvider.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,14 @@ class QInlineCompletionProvider(private val cs: CoroutineScope) : InlineCompleti
404404
CodeWhispererInvocationStatus.getInstance().setIsInvokingQInline(session, false)
405405
}
406406

407+
// this is only available in 2024.3+
408+
if (request.event.isDeletion()) {
409+
logInline(triggerSessionId) {
410+
"Skip inline completion when deleting"
411+
}
412+
return InlineCompletionSuggestion.Empty
413+
}
414+
407415
val sessionContext = InlineCompletionSessionContext(triggerOffset = request.endOffset)
408416

409417
// Pagination workaround: Always return exactly 5 variants

0 commit comments

Comments
 (0)