diff --git a/crates/gpui/src/elements/tooltip.rs b/crates/gpui/src/elements/tooltip.rs index 4c255e139ed7ab4a84d4e5ec2f8d1d8b885020ef..9fc5894c63e66514e5843359299594a453eff0dd 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()); }