From 78b31d046b8e524aa794b3c47b90cc40d81c7103 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sat, 16 May 2020 23:26:53 +0200 Subject: [PATCH] fix crash in help popup (closes #63) --- CHANGELOG.md | 3 +++ src/ui/mod.rs | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 325ea11c..a543bcf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- fix crash help in small window size ([#63](https://github.com/extrawurst/gitui/issues/63)) + ## [0.2.5] - 2020-05-16 ### Added - introduced proper changelog diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 2ec7f4f3..b8e241f3 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -47,10 +47,10 @@ pub fn centered_rect_absolute( r: Rect, ) -> Rect { Rect::new( - (r.width - width) / 2, - (r.height - height) / 2, - width, - height, + (r.width.saturating_sub(width)) / 2, + (r.height.saturating_sub(height)) / 2, + width.min(r.width), + height.min(r.height), ) }