RFR: 8182297: jshell tool: pasting multiple lines of code truncated

Robert Field robert.field at oracle.com
Wed Aug 16 17:48:23 UTC 2017


Thumbs up!

-Robert

On 06/27/17 11:14, Jan Lahoda wrote:
> Hi,
>
> Currently, when pasting multiple lines into JShell, only the first two 
> lines are used.
>
> The cause is that when 
> jdk.internal.jline.console.ConsoleReader.readLine, we need to read the 
> cursor position. This is e.g. to avoid backspacing into the prompt. I 
> believe standard JLine is solving this by determining the length of 
> the prompt, but that does not work well for JShell, as the prompt is 
> not always known (e.g. when using System.in).
>
> So, there's a code to query the cursor position - this is done by 
> writing a query to the terminal and reading the answer from the 
> standard input.
>
> But if there's something in the standard input before the answer, it 
> needs to be read as well. So, this is read and stored in a 
> queue/stack, but the problem is that the stack is a local variable in 
> the readLine method. So only one line of the input is used and the 
> rest is dropped. The reason why two lines are used after paste is that 
> the above happens for the second pasted line; the measurements for the 
> first line are usually already done for the first line, which is not 
> so affected.
>
> The proposed solution is to store the todo stack in a field.
>
> Bug:
> https://bugs.openjdk.java.net/browse/JDK-8182297
>
> Webrev:
> jdk repository:
> http://cr.openjdk.java.net/~jlahoda/8182297/jdk.00/
> langtools repository (test):
> http://cr.openjdk.java.net/~jlahoda/8182297/langtools.00/
>
> Thanks,
>    Jan



More information about the kulla-dev mailing list