summaryrefslogtreecommitdiffstats
path: root/src/render/markdown.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-11-03 18:36:17 +0800
committerGitHub <noreply@github.com>2023-11-03 18:36:17 +0800
commit887bf0a744646c6d9cfb361ba0c929d4a4342337 (patch)
tree3e3144e000f4f738fd495d8f5261d1f67f4dc3a0 /src/render/markdown.rs
parent811e605fbfd5b4973cbff9439db14c76c76b140f (diff)
downloadaichat-887bf0a744646c6d9cfb361ba0c929d4a4342337.tar.gz
fix: fix rendering markdown in REPL (#207)
Diffstat (limited to 'src/render/markdown.rs')
-rw-r--r--src/render/markdown.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/render/markdown.rs b/src/render/markdown.rs
index f491fc1..f300854 100644
--- a/src/render/markdown.rs
+++ b/src/render/markdown.rs
@@ -205,7 +205,9 @@ impl MarkdownRender {
fn wrap(text: &str, width: usize) -> String {
let indent: usize = text.chars().take_while(|c| *c == ' ').count();
- let wrap_options = textwrap::Options::new(width).initial_indent(&text[0..indent]);
+ let wrap_options = textwrap::Options::new(width)
+ .wrap_algorithm(textwrap::WrapAlgorithm::FirstFit)
+ .initial_indent(&text[0..indent]);
textwrap::wrap(&text[indent..], wrap_options).join("\n")
}