Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "bugfix",
"description" : "Fix inline chat default key binding not working on windows and linux"
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
apache-commons-collections = "4.4"
apache-commons-io = "2.16.0"
apache-commons-text = "1.12.0"
assertJ = "3.26.3"
# match with <root>/settings.gradle.kts
awsSdk = "2.26.25"
Expand Down Expand Up @@ -70,6 +71,7 @@ aws-sts = { module = "software.amazon.awssdk:sts", version.ref = "awsSdk" }
commonmark = { module = "org.commonmark:commonmark", version.ref = "commonmark" }
commons-collections = { module = "org.apache.commons:commons-collections4", version.ref = "apache-commons-collections" }
commons-io = { module = "commons-io:commons-io", version.ref = "apache-commons-io" }
commons-text = {module = "org.apache.commons:commons-text", version.ref = "apache-commons-text"}
detekt-api = { module = "io.gitlab.arturbosch.detekt:detekt-api", version.ref = "detekt" }
detekt-formattingRules = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
diff-util = { module = "io.github.java-diff-utils:java-diff-utils", version.ref = "diff-util" }
Expand Down
1 change: 1 addition & 0 deletions plugins/amazonq/chat/jetbrains-community/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {
// everything references codewhisperer, which is not ideal
implementation(project(":plugin-amazonq:codewhisperer:jetbrains-community"))
implementation(libs.diff.util)
implementation(libs.commons.text)

compileOnly(project(":plugin-core:jetbrains-community"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
factoryClass="software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindowFactory" icon="AwsIcons.Logos.AWS_Q" />

<postStartupActivity implementation="software.aws.toolkits.jetbrains.services.amazonq.startup.AmazonQStartupActivity"/>
<actionPromoter order="last" implementation="software.aws.toolkits.jetbrains.services.cwc.inline.InlineChatActionPromoter"/>
</extensions>

<extensions defaultExtensionNs="amazon.q">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.services.cwc.inline

import com.intellij.openapi.actionSystem.ActionPromoter
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.keymap.KeymapUtil
import com.intellij.openapi.util.SystemInfo

class InlineChatActionPromoter : ActionPromoter {

Check warning on line 13 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/inline/InlineChatActionPromoter.kt

View workflow job for this annotation

GitHub Actions / qodana

Extension class should be final and non-public

Extension class should not be public

Check warning

Code scanning / QDJVMC

Extension class should be final and non-public Warning

Extension class should not be public
// temporary until we find a better key binding
override fun promote(actions: MutableList<out AnAction>, context: DataContext): MutableList<AnAction> {
val results = actions.toMutableList()
if (context.getData(CommonDataKeys.EDITOR) == null ||
context.getData(CommonDataKeys.PROJECT) == null
) {
return results
}
val shortCut = KeymapUtil.getShortcutText("aws.toolkit.jetbrains.core.services.cwc.inline.openChat")
// only promote for the default key bindings
if (SystemInfo.isMac && shortCut != "⌘I") return results
if (!SystemInfo.isMac && shortCut != "Ctrl+I") return results

results.sortWith { a, b ->
when {
isOpenChatInputAction(a) -> -1
isOpenChatInputAction(b) -> 1
else -> 0
}
}
return results
}

private fun isOpenChatInputAction(action: AnAction): Boolean =
action is OpenChatInputAction
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.intellij.codeInsight.hint.HintUtil
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.VisualPosition
import com.intellij.openapi.keymap.KeymapUtil
import com.intellij.openapi.util.SystemInfo
import com.intellij.ui.LightweightHint
import com.intellij.ui.SimpleColoredText
import com.intellij.ui.SimpleTextAttributes
Expand Down Expand Up @@ -68,15 +67,9 @@ class InlineChatEditorHint {
coloredText.appendToComponent(component)
val shortcutComponent = HintUtil.createInformationComponent()
val shortCut = KeymapUtil.getShortcutText("aws.toolkit.jetbrains.core.services.cwc.inline.openChat")
if (!SystemInfo.isWindows && shortCut == "⌃I") {
val shortCutIcon = AwsIcons.Resources.InlineChat.AWS_Q_INLINECHAT_SHORTCUT
shortcutComponent.isIconOnTheRight = true
shortcutComponent.icon = shortCutIcon
} else {
val shortcutText =
SimpleColoredText(shortCut, SimpleTextAttributes.REGULAR_ATTRIBUTES)
shortcutText.appendToComponent(shortcutComponent)
}
val shortcutText =
SimpleColoredText(shortCut, SimpleTextAttributes.REGULAR_ATTRIBUTES)
shortcutText.appendToComponent(shortcutComponent)

val panel = JPanel(BorderLayout()).apply {
add(component, BorderLayout.WEST)
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions plugins/core/jetbrains-community/src/icons/AwsIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ object AwsIcons {

@JvmField val SEVERITY_CRITICAL = load("/icons/resources/codewhisperer/severity-critical.svg")
}

object InlineChat {
@JvmField val AWS_Q_INLINECHAT_SHORTCUT = load("/icons/resources/inlinechat/amazonq_inline_chat_shortcut.svg")
}
}

object Actions {
Expand Down
Loading