Skip to content

[WIP] Update JLine to v3 #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 25, 2018
Merged

Conversation

sake92
Copy link
Collaborator

@sake92 sake92 commented Mar 19, 2018

Logic rewritten to use JLine3 API. Some notable improvements:

  • autocomplete behaves like tabindex, you can select it 😲
  • multiline editing works awesome
  • multiline pasting works
  • multiline string inserts TAB instead of doing autocomplete (when blank line)
  • highlighting works fine
  • opening paren/bracket even blinks when you close a paren, OMG
  • Ctrl+Left/Ctrl+Right skips a word

Tests are passing, except ops/test? Seems unrelated, fails on other PRs also...

@lihaoyi
Copy link
Member

lihaoyi commented Mar 20, 2018

@sake92 haven't look at this yet, but let me know when it's ready and I will

@sake92
Copy link
Collaborator Author

sake92 commented Mar 23, 2018

@lihaoyi ready for review

@lihaoyi
Copy link
Member

lihaoyi commented Mar 23, 2018

I have no idea what's going on here, but it looks good to me 😛If you get this green I'll merge it

@robby-phd you're on windows right? Would you like to give this REPL a spin and see what you think?

@sake92
Copy link
Collaborator Author

sake92 commented Mar 23, 2018

@lihaoyi Hurry up and merge while it's green! 😄

@robby-phd
Copy link
Collaborator

robby-phd commented Mar 23, 2018

@lihaoyi I'm actually on mac 😁.

I do have a VM for testing on Windows 10, so I gave it a spin (using MSYS2 terminal; the following is after running sbt amm/test:assembly on @sake92's upgrade-to-jline3):

$ ammonite-version-SNAPSHOT-2.12.4
Loading...
Mar 23, 2018 5:39:15 AM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Compiling (synthetic)/ammonite/predef/interpBridge.sc
Compiling (synthetic)/ammonite/predef/replBridge.sc
Compiling (synthetic)/ammonite/predef/DefaultPredef.sc
Welcome to the Ammonite Repl version-SNAPSHOT
(Scala 2.12.4 Java 9.0.4.1)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ 2 + 1
......

@ Seq.fill(10)(Seq.fill(3)("Foo"))
Seq.fill(10)(Seq.fill(3)("Foo"))......

@ exit
Bye!

Using cmd (or with ConEmu for ANSI color, i.e., without --color false):

>java -jar -Xmx500m -XX:+UseG1GC ammonite-version-SNAPSHOT-2.12.4 --color false
Loading...
Compiling (synthetic)/ammonite/predef/interpBridge.sc
Compiling (synthetic)/ammonite/predef/replBridge.sc
Compiling (synthetic)/ammonite/predef/DefaultPredef.sc
Welcome to the Ammonite Repl version-SNAPSHOT
(Scala 2.12.4 Java 9.0.4.1)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ 2 + 1
res0: Int = 3

@ Seq.fill(10)(Seq.fill(3)("Foo"))
res1: Seq[Seq[String]] = List(
  List("Foo", "Foo", "Foo"),
  List("Foo", "Foo", "Foo"),
  List("Foo", "Foo", "Foo"),
  List("Foo", "Foo", "Foo"),
  List("Foo", "Foo", "Foo"),
  List("Foo", "Foo", "Foo"),
  List("Foo", "Foo", "Foo"),
  List("Foo", "Foo", "Foo"),
  List("Foo", "Foo", "Foo"),
  List("Foo", "Foo", "Foo")
)

@ exit
Bye!

On master (MSYS2):

$ ammonite-version-SNAPSHOT-2.12.4
Loading...
Compiling (synthetic)/ammonite/predef/replBridge.sc
Compiling (synthetic)/ammonite/predef/DefaultPredef.sc
Welcome to the Ammonite Repl version-SNAPSHOT
(Scala 2.12.4 Java 9.0.4.1)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
sh: /dev/tty: No such device or address
sh: /dev/tty: No such device or address
java.lang.RuntimeException: Nonzero exit value: 1
  scala.sys.package$.error(package.scala:27)
  scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:134)
  scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:104)
  ammonite.terminal.TTY$.stty(Utils.scala:118)
  ammonite.terminal.TTY$.init(Utils.scala:97)
  ammonite.terminal.Terminal$.x$1$lzycompute$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.x$1$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.initialConfig$lzycompute$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.initialConfig$1(Terminal.scala:41)
  ammonite.terminal.Terminal$.readLine(Terminal.scala:52)
  ammonite.repl.AmmoniteFrontEnd.readLine(AmmoniteFrontEnd.scala:131)
  ammonite.repl.AmmoniteFrontEnd.action(AmmoniteFrontEnd.scala:25)
  ammonite.repl.Repl.$anonfun$action$1(Repl.scala:157)
  ammonite.util.Catching.flatMap(Res.scala:114)
  ammonite.repl.Repl.action(Repl.scala:141)
  ammonite.repl.Repl.loop$1(Repl.scala:181)
  ammonite.repl.Repl.run(Repl.scala:197)
  ammonite.Main.$anonfun$run$2(Main.scala:201)
  scala.Option.getOrElse(Option.scala:121)
  ammonite.Main.run(Main.scala:188)
  ammonite.MainRunner.$anonfun$runRepl$1(Main.scala:370)
  ammonite.MainRunner.watchLoop(Main.scala:351)
  ammonite.MainRunner.runRepl(Main.scala:370)
  ammonite.Main$.main0(Main.scala:287)
  ammonite.Main$.main(Main.scala:251)
  ammonite.Main.main(Main.scala)

...

So, it's definitely much better for Windows support, though I'm not sure why in MSYS2 it's showing ...... for the repl result.

Note that ammonite.terminals.Utils (still) assumes sh, however, that code path does not seem to be executed; jline3 does seem to have support for tty.

@lihaoyi lihaoyi merged commit af54e9d into com-lihaoyi:master Mar 25, 2018
@lihaoyi
Copy link
Member

lihaoyi commented Mar 26, 2018

CC @adriaanm since you have been looking at jline3 too; feel free to re-use this code for the Scala REPL!

@adriaanm
Copy link

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants