mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[terminal] IJPL-212254 Refactor: remove terminal tab from TerminalTabsManager unconditionally
Since there are no reconnections anymore and `TerminalTabsManager` lives on the frontend, this logic is not needed anymore. (cherry picked from commit e5e63ab109d6ed9dd7d008bb5c61e2ae5270571c) IJ-CR-214214 GitOrigin-RevId: 5da809a0434eb28fc2049e8177a3065f22f143b5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9c8de804c3
commit
1878b3f019
+1
-18
@@ -8,7 +8,6 @@ import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.application.UI
|
||||
import com.intellij.openapi.application.asContextElement
|
||||
import com.intellij.openapi.components.serviceIfCreated
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.Key
|
||||
@@ -309,17 +308,7 @@ internal class TerminalToolWindowTabsManagerImpl(
|
||||
val backendTabId = existingBackendTabId ?: TerminalTabsManager.getInstance(project).createNewTerminalTab().id
|
||||
|
||||
terminal.coroutineScope.awaitCancellationAndInvoke(Dispatchers.EDT) {
|
||||
// Backend terminal session tab lifecycle is not directly bound to the terminal frontend lifecycle.
|
||||
// We need to close the backend session when the terminal is closed explicitly.
|
||||
// And don't need it when a user is closing the project leaving the terminal tabs opened: to be able to reconnect back.
|
||||
// So we send close event only if the terminal is closed explicitly: backend will close it on its termination.
|
||||
// It is not easy to determine whether it is explicit closing or not, so we use the heuristic.
|
||||
if (!isTerminalToolWindowClosing()) {
|
||||
// Do not block frontend terminal scope cancellation by backend session termination request.
|
||||
coroutineScope.launch {
|
||||
TerminalTabsManager.getInstance(project).closeTerminalTab(backendTabId)
|
||||
}
|
||||
}
|
||||
TerminalTabsManager.getInstance(project).closeTerminalTab(backendTabId)
|
||||
}
|
||||
|
||||
// Ideally, the backend tab should be under the tab scope, but now it has the lifecycle of the terminal scope
|
||||
@@ -396,12 +385,6 @@ internal class TerminalToolWindowTabsManagerImpl(
|
||||
installPortForwarding(terminal, terminal.coroutineScope.childScope("PortForwarding"))
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun isTerminalToolWindowClosing(): Boolean {
|
||||
val toolWindow = project.serviceIfCreated<ToolWindowManager>()?.getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID)
|
||||
return toolWindow?.contentManagerIfCreated?.isDisposed == true
|
||||
}
|
||||
|
||||
private fun getToolWindow(): ToolWindow {
|
||||
val toolWindow = ToolWindowManager.getInstance(project).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID)
|
||||
?: error("No terminal tool window found")
|
||||
|
||||
Reference in New Issue
Block a user