generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(terminal): add compatibility support for 222 and 233 versions
This commit introduces compatibility with both version 222 and 233 of the terminal extension. It includes a new ShellCommandSuggestionAction class that leverages the newly added TerminalUtil class to get the current terminal widget more efficiently. The TerminalUtil class has been split into two separate files, one for each version, to ensure compatibility and avoid breaking changes.
- Loading branch information
Showing
3 changed files
with
36 additions
and
15 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
exts/ext-terminal/src/222/main/kotlin/cc/unitmesh/terminal/TerminalUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cc.unitmesh.terminal | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.wm.ToolWindowManager | ||
import com.intellij.terminal.JBTerminalWidget | ||
import org.jetbrains.plugins.terminal.TerminalToolWindowFactory | ||
import org.jetbrains.plugins.terminal.TerminalView | ||
|
||
object TerminalUtil { | ||
fun getCurrentTerminalWidget(project: Project): JBTerminalWidget? { | ||
val toolWindow = ToolWindowManager.getInstance(project) | ||
.getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID) ?: return null | ||
val content = toolWindow.contentManager.selectedContent ?: return null | ||
val widget = TerminalView.getWidgetByContent(content) ?: return null | ||
return widget | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
exts/ext-terminal/src/233/main/kotlin/cc/unitmesh/terminal/TerminalUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cc.unitmesh.terminal | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.wm.ToolWindowManager | ||
import com.intellij.terminal.JBTerminalWidget | ||
import org.jetbrains.plugins.terminal.TerminalToolWindowFactory | ||
import org.jetbrains.plugins.terminal.TerminalToolWindowManager | ||
|
||
object TerminalUtil { | ||
fun getCurrentTerminalWidget(project: Project): JBTerminalWidget? { | ||
val toolWindow = ToolWindowManager.getInstance(project) | ||
.getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID) ?: return null | ||
val content = toolWindow.contentManager.selectedContent ?: return null | ||
val widget = TerminalToolWindowManager.getWidgetByContent(content) ?: return null | ||
return widget | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters