fix: uncorrected render in command mode (#188)

This commit is contained in:
sigoden 2023-10-31 10:26:44 +08:00 committed by GitHub
parent 680670e834
commit 9b614600c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -43,11 +43,13 @@ pub fn cmd_render_stream(
let output = render.render(&input);
let output = &output[col..];
let (_, tail) = split_line_tail(output);
if render.wrap_width().is_some() {
if output.contains('\n') {
col = display_width(tail);
} else {
col += display_width(output);
}
}
print_now!("{}", output);
}
}

View File

@ -71,6 +71,10 @@ impl MarkdownRender {
)
}
pub(crate) const fn wrap_width(&self) -> Option<u16> {
self.wrap_width
}
pub fn render(&mut self, text: &str) -> String {
text.split('\n')
.map(|line| self.render_line_mut(line))