mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed indentation problem in Execute in console (PY-7180).
This commit is contained in:
@@ -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(":");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -27,6 +27,10 @@ public class PyConsoleIndentTest extends UsefulTestCase{
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIndent5() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
String name = getTestName(true);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user