mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-15 18:02:58 +08:00
feat: insert new terminal tab at the correct index in terminal tab manager
This commit is contained in:
@@ -3,5 +3,5 @@ package app.termora
|
||||
import app.termora.actions.AnActionEvent
|
||||
import java.util.*
|
||||
|
||||
class OpenHostActionEvent(source: Any, val host: Host, event: EventObject) :
|
||||
class OpenHostActionEvent(source: Any, val host: Host, event: EventObject, val tabIndex: Int = -1) :
|
||||
AnActionEvent(source, String(), event)
|
||||
@@ -236,7 +236,7 @@ class TerminalTabbed(
|
||||
if (tab is HostTerminalTab) {
|
||||
actionManager
|
||||
.getAction(OpenHostAction.OPEN_HOST)
|
||||
.actionPerformed(OpenHostActionEvent(this, tab.host, evt))
|
||||
.actionPerformed(OpenHostActionEvent(this, tab.host, evt, tabIndex + 1))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,12 @@ class OpenHostAction : AnAction() {
|
||||
|
||||
if (tab == null) return
|
||||
|
||||
if (evt.tabIndex >= 0) {
|
||||
terminalTabbedManager.addTerminalTab(evt.tabIndex, tab)
|
||||
} else {
|
||||
terminalTabbedManager.addTerminalTab(tab)
|
||||
}
|
||||
|
||||
if (tab is PtyHostTerminalTab) {
|
||||
tab.start()
|
||||
}
|
||||
|
||||
@@ -27,9 +27,14 @@ class CloneSessionTerminalTabbedContextMenuExtension private constructor() : Ter
|
||||
cloneSession.addActionListener(object : AnAction() {
|
||||
override fun actionPerformed(evt: AnActionEvent) {
|
||||
val terminalTabbedManager = evt.getData(DataProviders.TerminalTabbedManager) ?: return
|
||||
val index = terminalTabbedManager.indexOfTerminalTab(tab)
|
||||
val handler = c.copy(channel = null)
|
||||
val newTab = SSHTerminalTab(windowScope, tab.host, handler)
|
||||
if (index >= 0) {
|
||||
terminalTabbedManager.addTerminalTab(index + 1, newTab)
|
||||
} else {
|
||||
terminalTabbedManager.addTerminalTab(newTab)
|
||||
}
|
||||
newTab.start()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user