diff options
| author | Michelle Tilley <michelle@michelletilley.net> | 2026-03-30 15:20:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-30 15:20:31 -0700 |
| commit | 0478a05320ff7bc4257633bc945bd750864d68d4 (patch) | |
| tree | 2e1abf5b0a49fe0270b70bd6385062ea81fb0ba1 /crates/atuin-ai/src/tui/components/markdown.rs | |
| parent | fix: replace `e>|` with `|` in nushell integration to restore history recordi... (diff) | |
| download | atuin-0478a05320ff7bc4257633bc945bd750864d68d4.zip | |
chore: Update to eye-declare 0.3.0 (#3365)
Diffstat (limited to 'crates/atuin-ai/src/tui/components/markdown.rs')
| -rw-r--r-- | crates/atuin-ai/src/tui/components/markdown.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/atuin-ai/src/tui/components/markdown.rs b/crates/atuin-ai/src/tui/components/markdown.rs index e1551a7f..1cd7dbcf 100644 --- a/crates/atuin-ai/src/tui/components/markdown.rs +++ b/crates/atuin-ai/src/tui/components/markdown.rs @@ -3,7 +3,7 @@ //! More robust than eye-declare's built-in Markdown component: //! uses a proper CommonMark parser rather than line-by-line regex. -use eye_declare::Component; +use eye_declare::{Component, props}; use pulldown_cmark::{Event, Parser, Tag, TagEnd}; use ratatui_core::{ buffer::Buffer, @@ -15,7 +15,7 @@ use ratatui_core::{ use ratatui_widgets::paragraph::{Paragraph, Wrap}; /// A markdown rendering component backed by pulldown-cmark. -#[derive(Default)] +#[props] pub struct Markdown { pub source: String, } @@ -73,14 +73,16 @@ impl Component for Markdown { .render(area, buf); } - fn desired_height(&self, width: u16, state: &Self::State) -> u16 { + fn desired_height(&self, width: u16, state: &Self::State) -> Option<u16> { if self.source.is_empty() || width == 0 { - return 0; + return Some(0); } let text = parse_markdown(&self.source, state); - Paragraph::new(text) - .wrap(Wrap { trim: false }) - .line_count(width) as u16 + Some( + Paragraph::new(text) + .wrap(Wrap { trim: false }) + .line_count(width) as u16, + ) } fn initial_state(&self) -> Option<MarkdownStyles> { |
