jline / jline3

JLine is a Java library for handling console input.
Other
1.46k stars 214 forks source link

IndexOutOfBoundsException in console-ui when header exceeds size of the terminal #1025

Closed ddom75 closed 1 month ago

ddom75 commented 2 months ago

When adding a header to a console-ui prompt, if the number of items in the header list is larger then the number of lines the terminal has to display, the program crashes. Here is the stack trace.

java.lang.IndexOutOfBoundsException: Index 74 out of bounds for length 5 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) at java.base/java.util.Objects.checkIndex(Objects.java:361)
at java.base/java.util.ArrayList.get(ArrayList.java:427) at org.jline.consoleui.prompt.AbstractPrompt.displayLines(AbstractPrompt.java:152) at org.jline.consoleui.prompt.AbstractPrompt.refreshDisplay(AbstractPrompt.java:116) at org.jline.consoleui.prompt.AbstractPrompt$InputValuePrompt.execute(AbstractPrompt.java:587)
at org.jline.consoleui.prompt.ConsolePrompt.prompt(ConsolePrompt.java:121) at org.jline.consoleui.examples.Basic.main(Basic.java:175)

I've attached a modified Basic.java example to demonstrate the problem. Basic.java.txt