From 6d732209cbf17b502bd81e37f70ec5fac94bd50c Mon Sep 17 00:00:00 2001 From: cossonleo Date: Mon, 30 May 2022 15:06:11 +0800 Subject: [PATCH] optimize competion preview pos --- helix-term/src/ui/completion.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index 38005aad033b9..c563d0a5245cc 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -385,6 +385,16 @@ impl Component for Completion { height = rel_height.min(height); } Rect::new(x, y, width, height) + } else if popup_x > 30 { + let mut height = area.height.saturating_sub(popup_y); + let mut width = popup_x; + if let Some((rel_width, rel_height)) = markdown_doc.required_size((width, height)) { + width = rel_width.min(width); + height = rel_height.min(height); + } + let x = popup_x - width; + let y = popup_y; + Rect::new(x, y, width, height) } else { let half = area.height / 2; let height = 15.min(half);