Skip to content

Commit 95ee0a0

Browse files
committed
auto merge of #12980 : cmr/rust/overhaul-stdio, r=thestinger
this comes from a discussion on IRC where the split between stdin and stdout seemed unnatural, and the fact that reading on stdin won't flush stdout, which is unlike every other language (including C's stdio).
2 parents 4224147 + 8fee3f6 commit 95ee0a0

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)