diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala b/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala index 5082c99a76..b5db4c2098 100644 --- a/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala +++ b/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala @@ -10,7 +10,8 @@ package scala.tools.nsc.interpreter.jline import java.util.{Collection => JCollection, List => JList} import _root_.jline.{console => jconsole} -import jconsole.completer.{Completer, ArgumentCompleter} +import jline.console.ConsoleReader +import jline.console.completer.{CompletionHandler, Completer, ArgumentCompleter} import jconsole.history.{History => JHistory} @@ -142,6 +143,27 @@ private class JLineConsoleReader extends jconsole.ConsoleReader with interpreter case NoCompletion => () case _ => this addCompleter completer } + + // This is a workaround for https://github.com/jline/jline2/issues/208 + // and should not be necessary once we upgrade to JLine 2.13.1 + /// + // Test by: + // scala> {" ".char}<LEFT><TAB> + // + // And checking we don't get an extra } on the line. + /// + val handler = getCompletionHandler + setCompletionHandler(new CompletionHandler { + override def complete(consoleReader: ConsoleReader, list: JList[CharSequence], i: Int): Boolean = { + try { + handler.complete(consoleReader, list, i) + } finally if (getCursorBuffer.cursor != getCursorBuffer.length()) { + print(" ") + getCursorBuffer.write(' ') + backspace() + } + } + }) setAutoprintThreshold(400) // max completion candidates without warning } } |