summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2017-03-14 10:39:35 -0700
committerSom Snytt <som.snytt@gmail.com>2017-03-14 10:39:35 -0700
commitc77b420769f2b25d218156ec0a3374c36d87bef5 (patch)
tree30acbdfb86bca693ef974fbebc774fa79fb1f10d /src
parentd0c26206e6fac16d4a24c1795628088e20228b48 (diff)
downloadscala-c77b420769f2b25d218156ec0a3374c36d87bef5.tar.gz
scala-c77b420769f2b25d218156ec0a3374c36d87bef5.tar.bz2
scala-c77b420769f2b25d218156ec0a3374c36d87bef5.zip
SI-10226 REPL handles paste when colorized
Colorization or Colourisation tripped up REPL on paste. Prompt detection should use the plain text prompt, not the ansified prompt. Manual test since .flags doesn't like it: ``` $ ./build/pack/bin/scala -Dscala.repl.prompt="%nhello > " Welcome to Scala 2.12.2-20170314-033334-d0c2620 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111). Type in expressions for evaluation. Or try :help. hello > 42 res0: Int = 42 hello > hello > 42 // Detected repl transcript. Paste more, or ctrl-D to finish. hello > "wtf?" // Replaying 2 commands from transcript. hello > 42 res1: Int = 42 hello > "wtf?" res2: String = wtf? hello > ```
Diffstat (limited to 'src')
-rw-r--r--src/repl/scala/tools/nsc/interpreter/ILoop.scala2
-rw-r--r--src/repl/scala/tools/nsc/interpreter/Pasted.scala7
2 files changed, 4 insertions, 5 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala
index 9635f320fe..8be4d159f1 100644
--- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala
@@ -768,7 +768,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
result
}
- private object paste extends Pasted(prompt) {
+ private object paste extends Pasted(replProps.promptText) {
def interpret(line: String) = intp interpret line
def echo(message: String) = ILoop.this echo message
diff --git a/src/repl/scala/tools/nsc/interpreter/Pasted.scala b/src/repl/scala/tools/nsc/interpreter/Pasted.scala
index 3a7eda1b77..7ab5e5bb42 100644
--- a/src/repl/scala/tools/nsc/interpreter/Pasted.scala
+++ b/src/repl/scala/tools/nsc/interpreter/Pasted.scala
@@ -38,10 +38,9 @@ abstract class Pasted(prompt: String) {
def matchesContinue(line: String) = matchesString(line, ContinueString)
def running = isRunning
- private def matchesString(line: String, target: String): Boolean = (
- (line startsWith target) ||
- (line.nonEmpty && spacey(line.head) && matchesString(line.tail, target))
- )
+ private def matchesString(line: String, target: String): Boolean =
+ line.startsWith(target) || (line.nonEmpty && spacey(line.head) && matchesString(line.tail, target))
+
private def stripString(line: String, target: String) = line indexOf target match {
case -1 => line
case idx => line drop (idx + target.length)