diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-01-21 15:38:46 +0100 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-02-11 00:54:26 +0100 |
commit | 81d11514f40314d8a64c009c0810f08f695b3e18 (patch) | |
tree | 8f71c4c60e38dd43f411d30c1553f05b37a90e07 /src/library | |
parent | 59fc37ade773f66eb05c7b2cfebe03abaf767c51 (diff) | |
download | scala-81d11514f40314d8a64c009c0810f08f695b3e18.tar.gz scala-81d11514f40314d8a64c009c0810f08f695b3e18.tar.bz2 scala-81d11514f40314d8a64c009c0810f08f695b3e18.zip |
SI-8167 readLine shold flush output before reading input
As reported on scala-user:
> Using `scala.Predef.readLine(text: String, args: Any*)`
> on Windows causes strange behavior. If I am leaving some
> part of `text` unforced to be flushed (say, "---\nEnter new
> expression >") then "Enter new expression >" flushed only
> after Enter press. Still, it works fine on Ubuntu and (seems like)
> on MacOS.
>
> My workaround is to force `java.lang.System.out` (that readLine
> depends on to write welcome string) to flush output like
> "---\nEnter new expression >\n".
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/io/StdIn.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/library/scala/io/StdIn.scala b/src/library/scala/io/StdIn.scala index 36568b59b7..64836ecd6e 100644 --- a/src/library/scala/io/StdIn.scala +++ b/src/library/scala/io/StdIn.scala @@ -17,7 +17,7 @@ private[scala] trait StdIn { */ def readLine(): String = in.readLine() - /** Print formatted text to the default output and read a full line from the default input. + /** Print and flush formatted text to the default output, and read a full line from the default input. * Returns `null` if the end of the input stream has been reached. * * @param text the format of the text to print out, as in `printf`. @@ -26,6 +26,7 @@ private[scala] trait StdIn { */ def readLine(text: String, args: Any*): String = { printf(text, args: _*) + out.flush() readLine() } |