diff options
author | Paul Phillips <paulp@improving.org> | 2012-03-19 16:14:58 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-03-19 16:41:17 -0700 |
commit | aafcc104b6ebe2fa163fc7a9cbfb742bf5f26d08 (patch) | |
tree | ff54fac219e9e1218bc4cd233b7e8370a35c66f8 /src | |
parent | 752884f1606320913ffe66f3bbf3db61746e2436 (diff) | |
download | scala-aafcc104b6ebe2fa163fc7a9cbfb742bf5f26d08.tar.gz scala-aafcc104b6ebe2fa163fc7a9cbfb742bf5f26d08.tar.bz2 scala-aafcc104b6ebe2fa163fc7a9cbfb742bf5f26d08.zip |
Chill out repl ctrl-char filter.
So colors can come through unscathed.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/Naming.scala | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/Naming.scala b/src/compiler/scala/tools/nsc/interpreter/Naming.scala index 8e215cf63b..19266442cb 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Naming.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Naming.scala @@ -11,16 +11,18 @@ package interpreter */ trait Naming { def unmangle(str: String): String = { + val ESC = '\u001b' val cleaned = removeIWPackages(removeLineWrapper(str)) - var ctrlChars = 0 - cleaned map { ch => - if (ch.isControl && !ch.isWhitespace) { - ctrlChars += 1 - if (ctrlChars > 5) return "[line elided for control chars: possibly a scala signature]" - else '?' - } - else ch - } + // Looking to exclude binary data which hoses the terminal, but + // let through the subset of it we need, like whitespace and also + // <ESC> for ansi codes. + val binaryChars = cleaned count (ch => ch < 32 && !ch.isWhitespace && ch != ESC) + // Lots of binary chars - translate all supposed whitespace into spaces + if (binaryChars > 5) + cleaned map (ch => if (ch.isWhitespace) ' ' else if (ch < 32) '?' else ch) + // Not lots - preserve whitespace and ESC + else + cleaned map (ch => if (ch.isWhitespace || ch == ESC) ch else if (ch < 32) '?' else ch) } // The two name forms this is catching are the two sides of this assignment: |