Skip to content

Commit 712d45c

Browse files
committed
feat(ext-terminal): refactor suggestCommand method to support 241 new UI context and add TerminalUtil class for message sending #135.
1 parent 41b4b7e commit 712d45c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object TerminalUtil {
1818
fun sendMsg(project: Project, data: String, e: AnActionEvent) {
1919
val content = getContent(project) ?: return
2020
val findWidgetByContent = TerminalToolWindowManager.findWidgetByContent(content) ?: return
21-
val controller: TerminalPromptController? = tryGetBlockTerminalEditor(findWidgetByContent)
21+
val controller: TerminalPromptController? = lookupTerminalPromptControllerByView(findWidgetByContent)
2222
if (controller == null) {
2323
trySendMsgInOld(project, data, content)
2424
return
@@ -36,7 +36,7 @@ object TerminalUtil {
3636
})
3737
}
3838

39-
private fun tryGetBlockTerminalEditor(findWidgetByContent: TerminalWidget): TerminalPromptController? {
39+
private fun lookupTerminalPromptControllerByView(findWidgetByContent: TerminalWidget): TerminalPromptController? {
4040
val terminalView = (findWidgetByContent.component as? Wrapper)?.targetComponent ?: return null
4141
if (terminalView is DataProvider) {
4242
val controller = terminalView.getData(TerminalPromptController.KEY.name)
@@ -56,9 +56,7 @@ object TerminalUtil {
5656
}
5757

5858
private fun getContent(project: Project): Content? {
59-
val toolWindow = ToolWindowManager.getInstance(project)
60-
.getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID)
61-
val content = toolWindow?.contentManager?.selectedContent
62-
return content
59+
val toolWindow = ToolWindowManager.getInstance(project).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID)
60+
return toolWindow?.contentManager?.selectedContent
6361
}
6462
}

0 commit comments

Comments
 (0)