From 3099caa87295782d945a18f4eebe7a2d2720d10c Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Wed, 10 Jan 2018 12:53:44 +0300 Subject: [PATCH] PyCharm doesn't allow to finish input (PY-27881) Update communication after console view creation and add check for nullability --- .../python/console/PydevConsoleCommunication.java | 10 ++++++---- .../python/console/PydevConsoleRunnerImpl.java | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java index ce636e5447a8..ac3535b99bd9 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java @@ -108,7 +108,7 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl private PythonDebugConsoleCommunication myDebugCommunication; private boolean myNeedsMore = false; - private PythonConsoleView myConsoleView; + private @Nullable PythonConsoleView myConsoleView; private List myFrameListeners = ContainerUtil.createLockFreeCopyOnWriteList(); /** @@ -234,7 +234,9 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl return execNotifyAboutMagic(params); } else if ("ShowConsole".equals(method)) { - myConsoleView.setConsoleEnabled(true); + if (myConsoleView != null) { + myConsoleView.setConsoleEnabled(true); + } return ""; } else { @@ -401,7 +403,7 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl return; //TODO: handle text input and other cases } nextResponse = null; - if (waitingForInput && myConsoleView.isInitialized()) { + if (waitingForInput && myConsoleView != null && myConsoleView.isInitialized()) { inputReceived = command.getText(); waitingForInput = false; //the thread that we started in the last exec is still alive if we were waiting for an input. @@ -791,7 +793,7 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl } } - public void setConsoleView(PythonConsoleView consoleView) { + public void setConsoleView(@Nullable PythonConsoleView consoleView) { myConsoleView = consoleView; } diff --git a/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java b/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java index a2fd4a56d806..c5d19c763988 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java @@ -607,8 +607,9 @@ public class PydevConsoleRunnerImpl implements PydevConsoleRunner { // Init console view myConsoleView = createConsoleView(); if (myConsoleView != null) { - ((JComponent)myConsoleView).setBorder(new SideBorder(JBColor.border(), SideBorder.LEFT)); + myConsoleView.setBorder(new SideBorder(JBColor.border(), SideBorder.LEFT)); } + myPydevConsoleCommunication.setConsoleView(myConsoleView); myProcessHandler = createProcessHandler(process); myConsoleExecuteActionHandler = createExecuteActionHandler();