Skip to content

Commit

Permalink
Strip escapes even when they fall at the edge between
Browse files Browse the repository at this point in the history
to calls to 'read'.
  • Loading branch information
dragos committed Apr 19, 2011
1 parent 09dcdaf commit 0b7732e
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -89,9 +89,20 @@ class SbtBuilder(project: ScalaProject) {
val reader = new BufferedReader(new InputStreamReader(is))
val writer = new PrintWriter(new OutputStreamWriter(consoleOutputStream), true)
var size = reader.read(buff, 0, BUFSIZE)
var rest = ""

while (size > 0) {
val str = new String(buff, 0, size)
writer.print(f(str))
val str = rest + new String(buff, 0, size)
val lastNl = str.lastIndexOf('\n')
val (prefix, postfix) = str.splitAt(lastNl)

writer.print(f(prefix))
rest = postfix

if (!rest.contains('\u001b')) {
writer.print(rest)
rest = ""
}
writer.flush()
size = reader.read(buff, 0, BUFSIZE)
}
Expand Down

0 comments on commit 0b7732e

Please sign in to comment.