Skip to content

Commit bd8d1f7

Browse files
committed
separate implementation for 2024.2 and 2024.3+
1 parent 58947d4 commit bd8d1f7

File tree

3 files changed

+9
-3
lines changed
  • plugins/amazonq/codewhisperer/jetbrains-community

3 files changed

+9
-3
lines changed

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

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

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package software.aws.toolkits.jetbrains.services.codewhisperer.popup
55
import com.intellij.codeInsight.inline.completion.InlineCompletionEvent
66
import com.intellij.openapi.editor.Editor
77
import com.intellij.openapi.util.UserDataHolderBase
8+
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider.Companion.DATA_KEY_Q_AUTO_TRIGGER_INTELLISENSE
89
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider.Companion.KEY_Q_AUTO_TRIGGER_INTELLISENSE
910
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider.Companion.Q_INLINE_PROVIDER_ID
1011

@@ -15,3 +16,7 @@ fun getManualCallEvent(editor: Editor, isIntelliSenseAccept: Boolean): InlineCom
1516
val data = UserDataHolderBase().apply { this.putUserData(KEY_Q_AUTO_TRIGGER_INTELLISENSE, isIntelliSenseAccept) }
1617
return InlineCompletionEvent.ManualCall(editor, Q_INLINE_PROVIDER_ID, data)
1718
}
19+
20+
fun InlineCompletionEvent.isDeletion(): Boolean =
21+
this is InlineCompletionEvent.Backspace
22+

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

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

407-
// ideally we want to use if (request.event is InlineCompletionEvent.Backspace) {
408-
// but this API is marked as experimental and it will not compile on 2024.2
409-
if (request.startOffset == request.endOffset) {
407+
// this is only available in 2024.3+
408+
if (request.event.isDeletion()) {
410409
logInline(triggerSessionId) {
411410
"Skip inline completion when deleting"
412411
}

0 commit comments

Comments
 (0)