From d02bbb7baec13e4d3c7ae0094431f2a20526cf18 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sun, 4 Jul 2021 20:05:01 +0800 Subject: [PATCH] Fix info panic on small terminal --- helix-term/src/ui/info.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/info.rs b/helix-term/src/ui/info.rs index c6f8db43d..e5f20562f 100644 --- a/helix-term/src/ui/info.rs +++ b/helix-term/src/ui/info.rs @@ -14,7 +14,12 @@ impl Component for Info { let Info { width, height, .. } = self; let (w, h) = (*width + 2, *height + 2); // -2 to subtract command line + statusline. a bit of a hack, because of splits. - let area = Rect::new(viewport.width - w, viewport.height - h - 2, w, h); + let area = viewport.intersection(Rect::new( + viewport.width.saturating_sub(w), + viewport.height.saturating_sub(h + 2), + w, + h, + )); surface.clear_with(area, style); let Rect { x, y, .. } = block.inner(area); for (y, line) in (y..).zip(self.text.lines()) {