aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/markdown.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui/markdown.rs')
-rw-r--r--helix-term/src/ui/markdown.rs15
1 files changed, 2 insertions, 13 deletions
diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs
index 6a7b641a..cfb5998c 100644
--- a/helix-term/src/ui/markdown.rs
+++ b/helix-term/src/ui/markdown.rs
@@ -247,19 +247,8 @@ impl Component for Markdown {
// TODO: account for tab width
let max_text_width = (viewport.0 - padding).min(120);
- let mut text_width = 0;
- let mut height = padding;
- for content in contents {
- height += 1;
- let content_width = content.width() as u16;
- if content_width > max_text_width {
- text_width = max_text_width;
- height += content_width / max_text_width;
- } else if content_width > text_width {
- text_width = content_width;
- }
- }
+ let (width, height) = crate::ui::text::required_size(&contents, max_text_width);
- Some((text_width + padding, height))
+ Some((width + padding * 2, height))
}
}