Skip to content

Commit 60d15ee

Browse files
committed
feat(ext-terminal): refactor suggestCommand method to support new UI context and add TerminalUtil class for message sending #135
This commit refactors the suggestCommand method in ShellCommandSuggestAction to support a new UI context. It also introduces the TerminalUtil class for sending messages, improving the extensibility and usability of the terminal extension.
1 parent 633e393 commit 60d15ee

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

exts/ext-terminal/src/222/main/kotlin/cc/unitmesh/terminal/TerminalUtil.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cc.unitmesh.terminal
22

33
import cc.unitmesh.terminal.ShellCommandSuggestAction.Companion.suggestCommand
4+
import com.intellij.openapi.actionSystem.AnActionEvent
45
import com.intellij.openapi.project.Project
56
import com.intellij.openapi.wm.ToolWindowManager
67
import com.intellij.terminal.JBTerminalWidget

exts/ext-terminal/src/233/main/kotlin/cc/unitmesh/terminal/TerminalUtil.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cc.unitmesh.terminal
22

33
import cc.unitmesh.terminal.ShellCommandSuggestAction.Companion.suggestCommand
4+
import com.intellij.openapi.actionSystem.AnActionEvent
45
import com.intellij.openapi.project.Project
56
import com.intellij.openapi.wm.ToolWindowManager
67
import com.intellij.terminal.JBTerminalWidget

exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/ShellCommandSuggestAction.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import cc.unitmesh.devti.statusbar.AutoDevStatusService
88
import cc.unitmesh.devti.template.GENIUS_PRACTISES
99
import cc.unitmesh.devti.template.TemplateRender
1010
import cc.unitmesh.devti.util.LLMCoroutineScope
11-
import com.intellij.openapi.actionSystem.AnAction
1211
import com.intellij.openapi.actionSystem.AnActionEvent
1312
import com.intellij.openapi.actionSystem.AnActionHolder
1413
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys
14+
import com.intellij.openapi.project.DumbAwareAction
1515
import com.intellij.openapi.project.Project
1616
import com.intellij.openapi.project.guessProjectDir
1717
import com.intellij.openapi.ui.popup.Balloon
@@ -25,7 +25,7 @@ import com.intellij.ui.components.JBLabel
2525
import com.intellij.util.ui.JBUI
2626
import com.intellij.util.ui.SwingHelper
2727
import com.intellij.util.ui.UIUtil
28-
import kotlinx.coroutines.flow.*
28+
import kotlinx.coroutines.flow.Flow
2929
import kotlinx.coroutines.launch
3030
import org.jetbrains.plugins.terminal.TerminalProjectOptionsProvider
3131
import java.awt.Component
@@ -40,14 +40,13 @@ private const val OUTLINE_PROPERTY = "JComponent.outline"
4040
private const val ERROR_VALUE = "error"
4141

4242

43-
class ShellCommandSuggestAction : AnAction() {
43+
class ShellCommandSuggestAction : DumbAwareAction() {
4444
override fun actionPerformed(e: AnActionEvent) {
4545
val project = e.project ?: return
4646
val contextComponent = e.getData(PlatformCoreDataKeys.CONTEXT_COMPONENT) ?: return
4747

48-
showContentRenamePopup(contextComponent, getPreferredPopupPoint(e)) { string ->
48+
showInputBoxPopup(contextComponent, getPreferredPopupPoint(e)) { string ->
4949
TerminalUtil.sendMsg(project, string, e)
50-
return@showContentRenamePopup
5150
}
5251
}
5352

@@ -63,7 +62,7 @@ class ShellCommandSuggestAction : AnAction() {
6362
return null
6463
}
6564

66-
private fun showContentRenamePopup(
65+
private fun showInputBoxPopup(
6766
component: Component, popupPoint: RelativePoint?,
6867
callback: (String) -> Unit
6968
) {

0 commit comments

Comments
 (0)