Skip to content

Commit e4e21bc

Browse files
committed
[GR-18339] Fix multiline input in repl
1 parent 3554042 commit e4e21bc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,13 +642,17 @@ public int readEvalPrint(Context context, ConsoleHandler consoleHandler) {
642642
continuePrompt = doEcho ? sys.getMember("ps2").asString() : null;
643643
}
644644
if (e.isIncompleteSource()) {
645-
// read another line of input
645+
// read more input until we get an empty line
646646
consoleHandler.setPrompt(continuePrompt);
647647
String additionalInput = consoleHandler.readLine();
648+
while (additionalInput != null && !additionalInput.isEmpty()) {
649+
sb.append(additionalInput).append('\n');
650+
consoleHandler.setPrompt(continuePrompt);
651+
additionalInput = consoleHandler.readLine();
652+
}
648653
if (additionalInput == null) {
649654
throw new EOFException();
650655
}
651-
sb.append(additionalInput).append('\n');
652656
// The only continuation in the while loop
653657
continue;
654658
} else if (e.isExit()) {

0 commit comments

Comments
 (0)