From 3d47813cda5b0a13b095f2681296dcae6adefd07 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 17 Jan 2010 20:50:47 +0000 Subject: Don't insert whitespace on multiline strings an... Don't insert whitespace on multiline strings and xml literals. Closes #2115. No review. --- src/compiler/scala/tools/nsc/Interpreter.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index 1185600c94..b2c5bc2415 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -240,13 +240,18 @@ class Interpreter(val settings: Settings, out: PrintWriter) * This way, compiler error messages read better. */ private final val spaces = List.fill(7)(" ").mkString - def indentCode(code: String) = + def indentCode(code: String) = { + /** Heuristic to avoid indenting and thereby corrupting """-strings and XML literals. */ + val noIndent = (code contains "\n") && (List("\"\"\"", "") exists (code contains _)) stringFrom(str => for (line <- code.lines) { - str.print(spaces) + if (!noIndent) + str.print(spaces) + str.print(line + "\n") str.flush() }) + } implicit def name2string(name: Name) = name.toString -- cgit v1.2.3