# HG changeset patch # User jlahoda # Date 1503400095 -7200 # Node ID 8e950730d2c8451cfa9ba7e67c19dac57fd8d75e # Parent 4c5a4cd5b092b53421360505a77b431ae7814d26 8182297: jshell tool: pasting multiple lines of code truncated Summary: Read input needs to be kept across ConsoleReader.readLine invocations unless consumed. Reviewed-by: rfield diff -r 4c5a4cd5b092 -r 8e950730d2c8 jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java --- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java Tue Aug 22 12:04:53 2017 +0530 +++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java Tue Aug 22 13:08:15 2017 +0200 @@ -29,6 +29,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -2338,8 +2339,6 @@ out.flush(); } - Stack pushBackChar = new Stack(); - if (terminal.isAnsiSupported() && System.console() != null) { //detect the prompt length by reading the cursor position from the terminal //the real prompt length could differ from the simple prompt length due to @@ -2357,9 +2356,11 @@ if (m.matches()) { promptLen = Integer.parseInt(m.group("column")) - 1; String prefix = m.group("prefix"); + List chars = new ArrayList<>(); for (int i = prefix.length() - 1; i >= 0; i--) { - pushBackChar.push(prefix.charAt(i)); + chars.add(prefix.charAt(i)); } + pushBackChar.addAll(0, chars); break; } } @@ -3224,6 +3225,7 @@ //where: private Pattern CURSOR_COLUMN_PATTERN = Pattern.compile("(?.*)\033\\[[0-9]+;(?[0-9]+)R", Pattern.DOTALL); + private Stack pushBackChar = new Stack(); /** * Read a line for unsupported terminals.