chore: recovery cursor in case of stream abort

This commit is contained in:
sigoden 2023-03-10 07:44:34 +08:00
parent 865fb49af9
commit 54e6edbf21

View File

@ -70,11 +70,16 @@ fn repl_render_stream_inner(
}
ReplyStreamEvent::Done => {
let output = markdown_render.render_line_stateless(&buffer);
queue!(writer, style::Print(output.trim_end()), style::Print("\n"))?;
if cfg!(windows) {
queue!(writer, style::Print("\n"))?;
let trimed_output = output.trim_end();
if !trimed_output.is_empty() {
queue!(writer, style::Print(output.trim_end()))?;
writer.flush()?;
}
let (_, row) = cursor::position()?;
queue!(writer, cursor::MoveTo(0, row), style::Print("\n\n"))?;
writer.flush()?;
break;
}
}