aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGokul Soumya2023-02-05 23:23:17 +0000
committerBlaž Hrastnik2023-02-11 07:05:23 +0000
commit1562b5ce67fbe4239de3b45d21f5853a4c123b99 (patch)
tree8481e3cc88805756a90d2214345d31198ea97aa8
parent0f844ef191af69da62c7a65b93db8a7e02cf86ff (diff)
Create popup rect instead of using raw values
-rw-r--r--helix-term/src/ui/completion.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index 7492b065..3d354bda 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -432,17 +432,18 @@ impl Component for Completion {
None => return,
};
- let (popup_x, popup_y) = self.popup.get_rel_position(area, cx);
- let (popup_width, _popup_height) = self.popup.get_size();
- let doc_width_available = area
- .width
- .saturating_sub(popup_x)
- .saturating_sub(popup_width);
+ let popup_area = {
+ let (popup_x, popup_y) = self.popup.get_rel_position(area, cx);
+ let (popup_width, popup_height) = self.popup.get_size();
+ Rect::new(popup_x, popup_y, popup_width, popup_height)
+ };
+
+ let doc_width_available = area.width.saturating_sub(popup_area.right());
let doc_area = if doc_width_available > 30 {
let mut doc_width = doc_width_available;
- let mut doc_height = area.height.saturating_sub(popup_y);
- let x = popup_x + popup_width;
- let y = popup_y;
+ let mut doc_height = area.height.saturating_sub(popup_area.top());
+ let x = popup_area.right();
+ let y = popup_area.top();
if let Some((rel_width, rel_height)) =
markdown_doc.required_size((doc_width, doc_height))