@@ -125,13 +125,13 @@ impl<T: Component> Component for Popup<T> {
125125 let mut rel_x = position.col as u16;
126126 let mut rel_y = position.row as u16;
127127 if viewport.width <= rel_x + width {
128− rel_x -= ((rel_x + width) - viewport.width)
128+ rel_x = rel_x.saturating_sub((rel_x + width).saturating_sub(viewport.width));
129129 };
130130
131131 // TODO: be able to specify orientation preference. We want above for most popups, below
132132 // for menus/autocomplete.
133133 if height <= rel_y {
134− rel_y -= height // position above point
134+ rel_y = rel_y.saturating_sub(height) // position above point
135135 } else {
136136 rel_y += 1 // position below point
137137 }