diff --git a/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java b/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java index 882441db9138..44ee034f3a44 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java @@ -144,16 +144,22 @@ public abstract class AbstractConsoleRunnerWithHistory 0 ? 1 : 0; + int max = 0; for (RunContentDescriptor dsc : consoles) { - try { - int num = Integer.parseInt(dsc.getDisplayName().substring(consoleTitle.length() + 1, dsc.getDisplayName().length() - 1)); - if (num > max) { - max = num; + ProcessHandler handler = dsc.getProcessHandler(); + if (handler != null && !handler.isProcessTerminated()) { + if (max == 0) { + max = 1; + } + try { + int num = Integer.parseInt(dsc.getDisplayName().substring(consoleTitle.length() + 1, dsc.getDisplayName().length() - 1)); + if (num > max) { + max = num; + } + } + catch (Exception e) { + //skip } - } - catch (Exception e) { - //skip } } if (max >= 1) {