From a38684ab4b7d728bb8120ca4cd4ae4ba5ef0902e Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Thu, 3 Mar 2011 14:33:13 +0300 Subject: [PATCH] Do not execute in stopped console. --- .../jetbrains/python/actions/ExecuteInConsoleAction.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/src/com/jetbrains/python/actions/ExecuteInConsoleAction.java b/python/src/com/jetbrains/python/actions/ExecuteInConsoleAction.java index aa7aabe30e33..a3755de55d2f 100644 --- a/python/src/com/jetbrains/python/actions/ExecuteInConsoleAction.java +++ b/python/src/com/jetbrains/python/actions/ExecuteInConsoleAction.java @@ -16,6 +16,7 @@ package com.jetbrains.python.actions; import com.intellij.execution.ExecutionHelper; +import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -105,11 +106,16 @@ public class ExecuteInConsoleAction extends AnAction { @NotNull @Override public Boolean fun(RunContentDescriptor dom) { - return dom.getExecutionConsole() instanceof PyCodeExecutor; + return dom.getExecutionConsole() instanceof PyCodeExecutor && isAlive(dom); } }); } + private static boolean isAlive(RunContentDescriptor dom) { + ProcessHandler processHandler = dom.getProcessHandler(); + return processHandler != null && !processHandler.isProcessTerminated(); + } + private static void findCodeExecutor(AnActionEvent e, Consumer consumer) { Editor editor = PlatformDataKeys.EDITOR.getData(e.getDataContext()); Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); @@ -132,7 +138,6 @@ public class ExecuteInConsoleAction extends AnAction { selectConsole(project, editor, consumer); } }); - } private static boolean canFindConsole(AnActionEvent e) {