Fix info panic on small terminal

pull/413/head
Ivan Tham 2021-07-04 20:05:01 +08:00 committed by Blaž Hrastnik
parent ebccc96cd4
commit d02bbb7bae
1 changed files with 6 additions and 1 deletions

View File

@ -14,7 +14,12 @@ impl Component for Info {
let Info { width, height, .. } = self; let Info { width, height, .. } = self;
let (w, h) = (*width + 2, *height + 2); let (w, h) = (*width + 2, *height + 2);
// -2 to subtract command line + statusline. a bit of a hack, because of splits. // -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); surface.clear_with(area, style);
let Rect { x, y, .. } = block.inner(area); let Rect { x, y, .. } = block.inner(area);
for (y, line) in (y..).zip(self.text.lines()) { for (y, line) in (y..).zip(self.text.lines()) {