diff options
| author | Corey Richardson <corey@octayn.net> | 2014-03-19 23:20:39 -0400 |
|---|---|---|
| committer | Corey Richardson <corey@octayn.net> | 2014-03-19 23:23:32 -0400 |
| commit | 8fee3f6f6e7155bb5316b2a6145ff3ef44c0824d (patch) | |
| tree | 8b503f6086c6befa30dcba2dce060fb7feb407c9 /src/libstd | |
| parent | 87e72c38122cbd24199365232217ca8c15ebe995 (diff) | |
| download | rust-8fee3f6f6e7155bb5316b2a6145ff3ef44c0824d.tar.gz rust-8fee3f6f6e7155bb5316b2a6145ff3ef44c0824d.zip | |
std: io: flush stdout on stdin read from tty
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/stdio.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 7c65e76ab47..7b3667a968a 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -296,7 +296,13 @@ pub struct StdReader { impl Reader for StdReader { fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { let ret = match self.inner { - TTY(ref mut tty) => tty.read(buf), + TTY(ref mut tty) => { + // Flush the task-local stdout so that weird issues like a + // print!'d prompt not being shown until after the user hits + // enter. + flush(); + tty.read(buf) + }, File(ref mut file) => file.read(buf).map(|i| i as uint), }; match ret { |
