Changesets · Branches · Tags · Compare
| Changeset | 2755bf5d2df43171c18abf949bcc097a2bf71c7be6281bc8e4cb74e27580e206 |
|---|---|
| Author | zimu <zimu@mgtv.com> · 2025-07-18 17:51 +08:00 |
| Committer | zimu <zimu@mgtv.com> · 2025-07-21 09:56 +08:00 |
| Parents | ce2e33429162 |
1 file changed
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +7 −3
| @@ -29,6 +29,7 @@ | ||
| 29 | 29 | import com.intellij.openapi.project.guessProjectDir |
| 30 | 30 | import com.intellij.openapi.vfs.LocalFileSystem |
| 31 | 31 | import com.intellij.openapi.vfs.VirtualFileManager |
| 32 | +import com.intellij.openapi.wm.ToolWindowManager | |
| 32 | 33 | import com.intellij.psi.PsiDocumentManager |
| 33 | 34 | import com.intellij.testFramework.LightVirtualFile |
| 34 | 35 | import kotlinx.coroutines.* |
| @@ -138,10 +139,13 @@ | ||
| 138 | 139 | override suspend fun getTerminalContents(): String { |
| 139 | 140 | return withContext(Dispatchers.EDT) { |
| 140 | 141 | try { |
| 142 | + val toolWindow = ToolWindowManager.getInstance(project).getToolWindow("Terminal") | |
| 143 | + | |
| 141 | 144 | val terminalView = TerminalView.getInstance(project) |
| 142 | - // Find the first terminal widget available, whatever its state. | |
| 143 | - val widget = | |
| 144 | - terminalView.getWidgets().filterIsInstance<ShellTerminalWidget>().firstOrNull { it.isEnabled } | |
| 145 | + // Find the first terminal widget selected, whatever its state, running command or not. | |
| 146 | + val widget = terminalView.getWidgets().filterIsInstance<ShellTerminalWidget>().firstOrNull { | |
| 147 | + toolWindow?.getContentManager()?.getContent(it)?.isSelected ?: false | |
| 148 | + } | |
| 145 | 149 | |
| 146 | 150 | if (widget != null) { |
| 147 | 151 | val textBuffer = widget.terminalTextBuffer |