From 0e1307fb23517ddbd658d0753d1cb3031677abca Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 1 Jun 2022 10:18:10 +0200 Subject: [PATCH] :memo: --- crates/gpui/src/elements/tooltip.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/gpui/src/elements/tooltip.rs b/crates/gpui/src/elements/tooltip.rs index 4c255e139e..9fc5894c63 100644 --- a/crates/gpui/src/elements/tooltip.rs +++ b/crates/gpui/src/elements/tooltip.rs @@ -102,9 +102,13 @@ impl Element for Tooltip { if let Some(tooltip) = self.tooltip.as_mut() { let origin = self.state.read(cx).position.get(); let mut bounds = RectF::new(origin, tooltip.size()); + + // Align tooltip to the left if its bounds overflow the window width. if bounds.lower_right().x() > cx.window_size.x() { bounds.set_origin_x(bounds.origin_x() - bounds.width()); } + + // Align tooltip to the top if its bounds overflow the window height. if bounds.lower_right().y() > cx.window_size.y() { bounds.set_origin_y(bounds.origin_y() - bounds.height()); }