From 2af04325d83cd0141400951252574666cffdf1af Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sun, 20 Feb 2022 14:44:44 +0900 Subject: fix: Allow multi-line prompt documentation --- helix-term/src/ui/prompt.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'helix-term/src/ui/prompt.rs') diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 18b390dd..7088d6df 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -389,12 +389,18 @@ impl Prompt { if let Some(doc) = (self.doc_fn)(&self.line) { let mut text = ui::Text::new(doc.to_string()); + let max_width = BASE_WIDTH * 3; + let padding = 1; + let viewport = area; + + let (_width, height) = ui::text::required_size(&text.contents, max_width); + let area = viewport.intersection(Rect::new( completion_area.x, - completion_area.y.saturating_sub(3), - BASE_WIDTH * 3, - 3, + completion_area.y.saturating_sub(height + padding * 2), + max_width, + height + padding * 2, )); let background = theme.get("ui.help"); @@ -402,8 +408,8 @@ impl Prompt { text.render( area.inner(&Margin { - vertical: 1, - horizontal: 1, + vertical: padding, + horizontal: padding, }), surface, cx, -- cgit v1.2.3-70-g09d2