summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-01-17 20:50:47 +0000
committerPaul Phillips <paulp@improving.org>2010-01-17 20:50:47 +0000
commit3d47813cda5b0a13b095f2681296dcae6adefd07 (patch)
tree206adfc1363fde190670b1450799f86cfa3dff09 /src/compiler
parent4bb4b8a08e4f6c85743d73e78729df01ec0212d7 (diff)
downloadscala-3d47813cda5b0a13b095f2681296dcae6adefd07.tar.gz
scala-3d47813cda5b0a13b095f2681296dcae6adefd07.tar.bz2
scala-3d47813cda5b0a13b095f2681296dcae6adefd07.zip
Don't insert whitespace on multiline strings an...
Don't insert whitespace on multiline strings and xml literals. Closes #2115. No review.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala9
1 files changed, 7 insertions, 2 deletions
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