diff --git a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/toolwindow/impl/TerminalProcessesClosingNotifier.kt b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/toolwindow/impl/TerminalProcessesClosingNotifier.kt index 22c4ee628403..cf8549b8f80e 100644 --- a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/toolwindow/impl/TerminalProcessesClosingNotifier.kt +++ b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/toolwindow/impl/TerminalProcessesClosingNotifier.kt @@ -8,6 +8,7 @@ import com.intellij.openapi.application.ApplicationListener import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.serviceIfCreated import com.intellij.openapi.extensions.ExtensionNotApplicableException +import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.project.Project import com.intellij.openapi.project.ProjectManager import com.intellij.openapi.project.VetoableProjectManagerListener @@ -19,12 +20,14 @@ import com.intellij.terminal.frontend.toolwindow.TerminalToolWindowTabsManager import com.intellij.terminal.frontend.view.TerminalView import com.intellij.terminal.ui.TerminalWidget import com.intellij.util.asDisposable +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope +import org.jetbrains.plugins.terminal.TerminalBundle import org.jetbrains.plugins.terminal.TerminalToolWindowManager import java.time.LocalDateTime @@ -78,9 +81,20 @@ internal object TerminalProcessesClosingNotifier : VetoableProjectManagerListene return true } - val tabTitlesToConfirm = runWithModalProgressBlocking(project, "") { - collectTabTitlesToConfirm(reworkedViews, classicWidgets) + val tabTitlesToConfirm = try { + runWithModalProgressBlocking(project, TerminalBundle.message("checking.running.terminal.processes.progress")) { + collectTabTitlesToConfirm(reworkedViews, classicWidgets) + } } + catch (_: CancellationException) { + ProgressManager.checkCanceled() + // User pressed "cancel" in the progress dialog. + // Since the user's intention is to close the project, + // consider that the user wants to skip any additional checks and finally close the project. + project.putUserData(PROCESSES_TERMINATION_CONFIRMED_TIME_KEY, LocalDateTime.now()) + return true + } + if (tabTitlesToConfirm.isEmpty()) { return true } diff --git a/plugins/terminal/resources/messages/TerminalBundle.properties b/plugins/terminal/resources/messages/TerminalBundle.properties index 136ae0b15155..3c444e9a580f 100644 --- a/plugins/terminal/resources/messages/TerminalBundle.properties +++ b/plugins/terminal/resources/messages/TerminalBundle.properties @@ -187,6 +187,7 @@ progress.text.running.terminal=Running the terminal\u2026 session.terminated.text=Session completed see.ide.log.error.description=See IDE log (Help | {0}) for the details. local.environment.name=Host +checking.running.terminal.processes.progress=Checking Running Terminal Processes closing.terminal.processes.progress=Closing Terminal Processes group.advanced.settings.terminal=Terminal