bug icon indicating copy to clipboard operation
bug copied to clipboard

REPL: IndexOutOfBoundsException with `-Xjline:vi`

Open som-snytt opened this issue 3 years ago • 3 comments

reproduction steps

➜  ~ scala -Xjline:vi
Welcome to Scala 2.13.8 (OpenJDK 64-Bit Server VM, Java 17.0.2).
Type in expressions for evaluation. Or try :help.

scala>
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: -6365, Size: 500
        at java.base/java.util.LinkedList.checkPositionIndex(LinkedList.java:564)
        at java.base/java.util.LinkedList.listIterator(LinkedList.java:871)
        at org.jline.reader.impl.history.DefaultHistory.iterator(DefaultHistory.java:442)
        at org.jline.reader.impl.LineReaderImpl.searchBackwards(LineReaderImpl.java:2842)
        at org.jline.reader.impl.LineReaderImpl.viRepeatSearch(LineReaderImpl.java:2037)
        at org.jline.reader.impl.LineReaderImpl.viHistorySearchBackward(LineReaderImpl.java:2029)
        at org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3778)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:679)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:468)
        at scala.tools.nsc.interpreter.jline.Reader.readOneLine(Reader.scala:44)
        at scala.tools.nsc.interpreter.shell.InteractiveReader.readLine(InteractiveReader.scala:38)
        at scala.tools.nsc.interpreter.shell.InteractiveReader.readLine$(InteractiveReader.scala:38)
        at scala.tools.nsc.interpreter.jline.Reader.readLine(Reader.scala:34)
        at scala.tools.nsc.interpreter.shell.ILoop.readOneLine(ILoop.scala:451)
        at scala.tools.nsc.interpreter.shell.ILoop.loop(ILoop.scala:456)
        at scala.tools.nsc.interpreter.shell.ILoop.run(ILoop.scala:968)
        at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:87)
        at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:91)
        at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:103)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:108)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

About to hit enter:

scala>
?util_

problem

They took away the history command and didn't tell me how to use jline history.

I tried something, but it looks broken.

som-snytt avatar Feb 11 '22 18:02 som-snytt

@som-snytt I'm not able to reproduce this on 2.13.12; are you?

SethTisue avatar Oct 25 '23 18:10 SethTisue

All my good ticket titles get edited by the editor, for some reason.

I'll give it a try. I miss vi bindings in REPL, and often think how I must track down how to fix it.

som-snytt avatar Oct 25 '23 18:10 som-snytt

I recently relearned about -Xjline:vi because they removed it.

This bug is when you hit ESC/ for search in vi. It displays as ? for searching backward in history, as in a shell.

I see the stack trace says viHistorySearchBackward.

som-snytt avatar Mar 22 '24 05:03 som-snytt