Hm, thanks for that, and given the following (cut down) version of the code that produced that:
term.write_line("Going to do some counting now").await?;
term.write_line(&format!("Counting {}/10", style(10).cyan())).await?;
term.clear_last_lines(1).await?;
term.write_line("Done counting!").await?;
term.write_line("Hello World!").await?;
term.write_str("To edit: ").await?;
Every method ends with a .flush().await at the end of the method call.
all ready tasks are eventually scheduled.
I'm guessing the non-sequential scheduling shouldn't be the cause of the non-sequential output in this case right?
Since the tasks are sequentially awaited, then it should be sequential (even with the non-sequential scheduler, since the tasks are sent one at a time).
Other observations:
In One, Done counting! (code line 4) is written over code line 1.
The clear_last_lines(1) terminal control character must be output twice, even if the code only writes it once. Perhaps this is, stdout internally has its own buffer, and flush()ing twice writes the same buffered bytes out.
In Two, code line 5 is written over code line 4
Done counting! is meant to be in output line 2, but it is in output line 3, and the \r brings the caret back to the beginning of the line for Hello World! to write over it. Somehow two \ns got written for Done counting! to move down an extra line. Possibly same explanation as the previous point.
One thing that may be relevant is, the flush() runs tokio::io::stdout().flush().await, instead of tokio::io::Stdout being held on the Term type. Maybe I'll try that.