diff --git a/python/src/com/jetbrains/python/console/PyConsoleIndentUtil.java b/python/src/com/jetbrains/python/console/PyConsoleIndentUtil.java index e64c60806c01..83568809455c 100644 --- a/python/src/com/jetbrains/python/console/PyConsoleIndentUtil.java +++ b/python/src/com/jetbrains/python/console/PyConsoleIndentUtil.java @@ -95,7 +95,7 @@ public class PyConsoleIndentUtil { } lastIndent = indentArray[i]; indentArray[i] -= indent; - if (lines.get(i).trim().endsWith(":")) { + if (shouldIndent(lines.get(i))) { lastIndented = true; } else { @@ -121,4 +121,12 @@ public class PyConsoleIndentUtil { return result.toString(); } + + public static boolean shouldIndent(@NotNull String line) { + if (line.contains("#")) { + line = line.substring(0, line.indexOf("#")); //strip comments + line = line.trim(); + } + return line.endsWith(":"); + } } diff --git a/python/src/com/jetbrains/python/console/PydevConsoleExecuteActionHandler.java b/python/src/com/jetbrains/python/console/PydevConsoleExecuteActionHandler.java index 6dc4e44b6e6b..68a7c3333286 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleExecuteActionHandler.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleExecuteActionHandler.java @@ -76,7 +76,7 @@ public class PydevConsoleExecuteActionHandler extends ConsoleExecuteActionHandle if (StringUtil.isEmptyOrSpaces(line)) { doProcessLine("\n"); } - else if (indentSize == 0 && indentSize < myCurrentIndentSize && !shouldIndent(line) && !myConsoleCommunication.isWaitingForInput()) { + else if (indentSize == 0 && indentSize < myCurrentIndentSize && !PyConsoleIndentUtil.shouldIndent(line) && !myConsoleCommunication.isWaitingForInput()) { doProcessLine("\n"); doProcessLine(line); } @@ -140,7 +140,7 @@ public class PydevConsoleExecuteActionHandler extends ConsoleExecuteActionHandle if (!StringUtil.isEmptyOrSpaces(line)) { int indent = IndentHelperImpl.getIndent(getProject(), PythonFileType.INSTANCE, line, false); boolean flag = false; - if (shouldIndent(line)) { + if (PyConsoleIndentUtil.shouldIndent(line)) { indent += getPythonIndent(); flag = true; } @@ -276,10 +276,6 @@ public class PydevConsoleExecuteActionHandler extends ConsoleExecuteActionHandle } } - private static boolean shouldIndent(String line) { - return line.endsWith(":"); - } - public int getPythonIndent() { return CodeStyleSettingsManager.getSettings(getProject()).getIndentSize(PythonFileType.INSTANCE); } diff --git a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java index 8b91415c6719..f980a7f859c5 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java @@ -176,6 +176,8 @@ public class PyDebugRunner extends GenericProgramRunner { debugParams.addParameter("--DEBUG"); } + //debugParams.addParameter("--save-signatures"); + final String[] debuggerArgs = new String[]{ CLIENT_PARAM, "127.0.0.1", PORT_PARAM, String.valueOf(serverLocalPort), diff --git a/python/testData/console/indent5.after.py b/python/testData/console/indent5.after.py new file mode 100644 index 000000000000..00d19a903408 --- /dev/null +++ b/python/testData/console/indent5.after.py @@ -0,0 +1,4 @@ +def dN(x,mu,si): # pdf normal distribution + z = (x - mu) / si + return exp(-0.5 * z ** 2) / sqrt(2 * pi * si ** 2) +S0 = 100.0 # initial index level \ No newline at end of file diff --git a/python/testData/console/indent5.py b/python/testData/console/indent5.py new file mode 100644 index 000000000000..00d19a903408 --- /dev/null +++ b/python/testData/console/indent5.py @@ -0,0 +1,4 @@ +def dN(x,mu,si): # pdf normal distribution + z = (x - mu) / si + return exp(-0.5 * z ** 2) / sqrt(2 * pi * si ** 2) +S0 = 100.0 # initial index level \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyConsoleIndentTest.java b/python/testSrc/com/jetbrains/python/PyConsoleIndentTest.java index 6a3545ba44db..8deef4254f68 100644 --- a/python/testSrc/com/jetbrains/python/PyConsoleIndentTest.java +++ b/python/testSrc/com/jetbrains/python/PyConsoleIndentTest.java @@ -27,6 +27,10 @@ public class PyConsoleIndentTest extends UsefulTestCase{ doTest(); } + public void testIndent5() { + doTest(); + } + private void doTest() { String name = getTestName(true); try {