Skip to content

Commit 6793afc

Browse files
authored
Merge branch 'main' into fixError
2 parents 4c52dea + db2e39f commit 6793afc

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

.changes/3.53.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"date" : "2025-02-07",
3+
"version" : "3.53",
4+
"entries" : [ {
5+
"type" : "bugfix",
6+
"description" : "Amazon Q: Fixed an issue where in a specific scenario when receiving multiple suggestions with JetBrains suggestions visible, users are not able to accept the suggestion."
7+
} ]
8+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# _3.53_ (2025-02-07)
2+
- **(Bug Fix)** Amazon Q: Fixed an issue where in a specific scenario when receiving multiple suggestions with JetBrains suggestions visible, users are not able to accept the suggestion.
3+
14
# _3.52_ (2025-02-06)
25
- **(Feature)** Adds event listener for notifying UI that AB feature configurations have been resolved
36
- **(Feature)** Amazon Q /review: Code issues can now be grouped by severity or file location.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# Toolkit Version
5-
toolkitVersion=3.53-SNAPSHOT
5+
toolkitVersion=3.54-SNAPSHOT
66

77
# Publish Settings
88
publishToken=

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

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ import com.intellij.ui.popup.AbstractPopup
4141
import com.intellij.ui.popup.PopupFactoryImpl
4242
import com.intellij.util.messages.Topic
4343
import com.intellij.util.ui.UIUtil
44-
import kotlinx.coroutines.sync.Semaphore
4544
import software.amazon.awssdk.services.codewhispererruntime.model.Import
4645
import software.amazon.awssdk.services.codewhispererruntime.model.Reference
4746
import software.aws.toolkits.core.utils.debug
48-
import software.aws.toolkits.core.utils.error
4947
import software.aws.toolkits.core.utils.getLogger
5048
import software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhispererEditorManager
5149
import software.aws.toolkits.jetbrains.services.codewhisperer.layout.CodeWhispererLayoutConfig.addHorizontalGlue
@@ -88,8 +86,8 @@ import javax.swing.JLabel
8886
class CodeWhispererPopupManager {
8987
val popupComponents = CodeWhispererPopupComponents()
9088

91-
// Act like a semaphore: one increment only corresponds to one decrement
92-
var allowEditsDuringSuggestionPreview = Semaphore(MAX_EDIT_SOURCE_DURING_SUGGESTION_PREVIEW)
89+
var allowTypingDuringSuggestionPreview = false
90+
var allowIntelliSenseDuringSuggestionPreview = false
9391
var sessionContext = SessionContext()
9492
private set
9593

@@ -251,18 +249,11 @@ class CodeWhispererPopupManager {
251249

252250
// Don't want to block or throw any kinds of exceptions here if it can continue to provide suggestions
253251
fun dontClosePopupAndRun(runnable: () -> Unit) {
254-
if (allowEditsDuringSuggestionPreview.tryAcquire()) {
255-
try {
256-
runnable()
257-
} finally {
258-
try {
259-
allowEditsDuringSuggestionPreview.release()
260-
} catch (e: Exception) {
261-
LOG.error(e) { "Failed to release allowEditsDuringSuggestionPreview semaphore" }
262-
}
263-
}
264-
} else {
265-
LOG.error { "Failed to acquire allowEditsDuringSuggestionPreview semaphore" }
252+
try {
253+
allowTypingDuringSuggestionPreview = true
254+
runnable()
255+
} finally {
256+
allowTypingDuringSuggestionPreview = false
266257
}
267258
}
268259

@@ -511,7 +502,7 @@ class CodeWhispererPopupManager {
511502
val editor = states.requestContext.editor
512503
val codewhispererSelectionListener: SelectionListener = object : SelectionListener {
513504
override fun selectionChanged(event: SelectionEvent) {
514-
if (allowEditsDuringSuggestionPreview.availablePermits == MAX_EDIT_SOURCE_DURING_SUGGESTION_PREVIEW) {
505+
if (!allowTypingDuringSuggestionPreview && !allowIntelliSenseDuringSuggestionPreview) {
515506
cancelPopup(states.popup)
516507
}
517508
super.selectionChanged(event)
@@ -527,7 +518,7 @@ class CodeWhispererPopupManager {
527518
if (!delete) return
528519
if (editor.caretModel.offset == event.offset) {
529520
changeStates(states, 0)
530-
} else if (allowEditsDuringSuggestionPreview.availablePermits == MAX_EDIT_SOURCE_DURING_SUGGESTION_PREVIEW) {
521+
} else if (!allowTypingDuringSuggestionPreview && !allowIntelliSenseDuringSuggestionPreview) {
531522
cancelPopup(states.popup)
532523
}
533524
}
@@ -536,7 +527,7 @@ class CodeWhispererPopupManager {
536527

537528
val codewhispererCaretListener: CaretListener = object : CaretListener {
538529
override fun caretPositionChanged(event: CaretEvent) {
539-
if (allowEditsDuringSuggestionPreview.availablePermits == MAX_EDIT_SOURCE_DURING_SUGGESTION_PREVIEW) {
530+
if (!allowTypingDuringSuggestionPreview && !allowIntelliSenseDuringSuggestionPreview) {
540531
cancelPopup(states.popup)
541532
}
542533
super.caretPositionChanged(event)

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import com.intellij.codeInsight.lookup.LookupEvent
88
import com.intellij.codeInsight.lookup.LookupListener
99
import com.intellij.codeInsight.lookup.LookupManagerListener
1010
import com.intellij.codeInsight.lookup.impl.LookupImpl
11-
import software.aws.toolkits.core.utils.error
11+
import com.intellij.openapi.util.Disposer
1212
import software.aws.toolkits.core.utils.getLogger
1313
import software.aws.toolkits.jetbrains.services.codewhisperer.model.InvocationContext
1414
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager
15-
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.listeners.CodeWhispererPopupIntelliSenseAcceptListener.Companion.LOG
1615
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus
1716

1817
class CodeWhispererPopupIntelliSenseAcceptListener(private val states: InvocationContext) : LookupManagerListener {
@@ -28,10 +27,8 @@ class CodeWhispererPopupIntelliSenseAcceptListener(private val states: Invocatio
2827
}
2928

3029
fun addIntelliSenseAcceptListener(lookup: Lookup, states: InvocationContext) {
31-
if (!CodeWhispererPopupManager.getInstance().allowEditsDuringSuggestionPreview.tryAcquire()) {
32-
LOG.error { "Failed to acquire allowEditsDuringSuggestionPreview semaphore" }
33-
}
34-
lookup.addLookupListener(object : LookupListener {
30+
CodeWhispererPopupManager.getInstance().allowIntelliSenseDuringSuggestionPreview = true
31+
val listener = object : LookupListener {
3532
override fun itemSelected(event: LookupEvent) {
3633
if (!CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive() ||
3734
!(event.lookup as LookupImpl).isShown
@@ -52,11 +49,12 @@ fun addIntelliSenseAcceptListener(lookup: Lookup, states: InvocationContext) {
5249

5350
private fun cleanup() {
5451
lookup.removeLookupListener(this)
55-
try {
56-
CodeWhispererPopupManager.getInstance().allowEditsDuringSuggestionPreview.release()
57-
} catch (e: Exception) {
58-
LOG.error(e) { "Failed to release allowEditsDuringSuggestionPreview semaphore" }
59-
}
52+
CodeWhispererPopupManager.getInstance().allowIntelliSenseDuringSuggestionPreview = false
6053
}
61-
})
54+
}
55+
lookup.addLookupListener(listener)
56+
Disposer.register(states) {
57+
lookup.removeLookupListener(listener)
58+
CodeWhispererPopupManager.getInstance().allowIntelliSenseDuringSuggestionPreview = false
59+
}
6260
}

0 commit comments

Comments
 (0)