diff options
author | Ivan Tham | 2021-07-04 12:05:01 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-07-04 15:19:56 +0000 |
commit | d02bbb7baec13e4d3c7ae0094431f2a20526cf18 (patch) | |
tree | 4ed8b71e0b88c11161797ecb04b729fcb588dc9f /helix-term/src/ui/info.rs | |
parent | ebccc96cd42d552db7df13249d71177fc016f0f1 (diff) |
Fix info panic on small terminal
Diffstat (limited to 'helix-term/src/ui/info.rs')
-rw-r--r-- | helix-term/src/ui/info.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/helix-term/src/ui/info.rs b/helix-term/src/ui/info.rs index c6f8db43..e5f20562 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()) { |