summaryrefslogtreecommitdiff
path: root/src/repl-jline
diff options
context:
space:
mode:
Diffstat (limited to 'src/repl-jline')
-rw-r--r--src/repl-jline/scala/tools/nsc/interpreter/jline/JLineDelimiter.scala2
-rw-r--r--src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala40
2 files changed, 23 insertions, 19 deletions
diff --git a/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineDelimiter.scala b/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineDelimiter.scala
index c18a9809a0..89e849429d 100644
--- a/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineDelimiter.scala
+++ b/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineDelimiter.scala
@@ -11,7 +11,7 @@ import _root_.jline.console.completer.ArgumentCompleter.{ ArgumentDelimiter, Arg
// implements a jline interface
class JLineDelimiter extends ArgumentDelimiter {
- def toJLine(args: List[String], cursor: Int) = args match {
+ def toJLine(args: List[String], cursor: Int): ArgumentList = args match {
case Nil => new ArgumentList(new Array[String](0), 0, 0, cursor)
case xs => new ArgumentList(xs.toArray, xs.size - 1, xs.last.length, cursor)
}
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 f0fce13fe8..5082c99a76 100644
--- a/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala
+++ b/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala
@@ -15,7 +15,7 @@ import jconsole.history.{History => JHistory}
import scala.tools.nsc.interpreter
-import scala.tools.nsc.interpreter.Completion
+import scala.tools.nsc.interpreter.{Completion, JLineCompletion, NoCompletion}
import scala.tools.nsc.interpreter.Completion.Candidates
import scala.tools.nsc.interpreter.session.History
@@ -121,23 +121,27 @@ private class JLineConsoleReader extends jconsole.ConsoleReader with interpreter
def initCompletion(completion: Completion): Unit = {
this setBellEnabled false
- if (completion ne interpreter.NoCompletion) {
- val jlineCompleter = new ArgumentCompleter(new JLineDelimiter,
- new Completer {
- val tc = completion.completer()
- def complete(_buf: String, cursor: Int, candidates: JList[CharSequence]): Int = {
- val buf = if (_buf == null) "" else _buf
- val Candidates(newCursor, newCandidates) = tc.complete(buf, cursor)
- newCandidates foreach (candidates add _)
- newCursor
- }
- }
- )
-
- jlineCompleter setStrict false
-
- this addCompleter jlineCompleter
- this setAutoprintThreshold 400 // max completion candidates without warning
+ // adapt the JLine completion interface
+ def completer =
+ new Completer {
+ val tc = completion.completer()
+ def complete(_buf: String, cursor: Int, candidates: JList[CharSequence]): Int = {
+ val buf = if (_buf == null) "" else _buf
+ val Candidates(newCursor, newCandidates) = tc.complete(buf, cursor)
+ newCandidates foreach (candidates add _)
+ newCursor
+ }
+ }
+
+ // a last bit of nastiness: parsing help depending on the flavor of completer (fixme)
+ completion match {
+ case _: JLineCompletion =>
+ val jlineCompleter = new ArgumentCompleter(new JLineDelimiter, completer)
+ jlineCompleter setStrict false
+ this addCompleter jlineCompleter
+ case NoCompletion => ()
+ case _ => this addCompleter completer
}
+ setAutoprintThreshold(400) // max completion candidates without warning
}
}