Skip to content

Commit 8fee3f6

Browse files
committed
std: io: flush stdout on stdin read from tty
1 parent 87e72c3 commit 8fee3f6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libstd/io/stdio.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,13 @@ pub struct StdReader {
296296
impl Reader for StdReader {
297297
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
298298
let ret = match self.inner {
299-
TTY(ref mut tty) => tty.read(buf),
299+
TTY(ref mut tty) => {
300+
// Flush the task-local stdout so that weird issues like a
301+
// print!'d prompt not being shown until after the user hits
302+
// enter.
303+
flush();
304+
tty.read(buf)
305+
},
300306
File(ref mut file) => file.read(buf).map(|i| i as uint),
301307
};
302308
match ret {

0 commit comments

Comments
 (0)