From 87676295a0d79d57a660ebbc9490abcb74f04c4c Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 6 Mar 2017 14:53:10 -0800 Subject: [PATCH] fix: Check for insufficient space in Panel::required_size --- src/views/panel.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/views/panel.rs b/src/views/panel.rs index 8b1b1f1..64a11dd 100644 --- a/src/views/panel.rs +++ b/src/views/panel.rs @@ -20,7 +20,13 @@ impl ViewWrapper for Panel { fn wrap_required_size(&mut self, req: Vec2) -> Vec2 { // TODO: make borders conditional? - self.view.required_size(req - (2, 2)) + (2, 2) + let req = if Vec2::new(2, 2).fits_in(req) { + req - (2, 2) + } else { + Vec2::zero() + }; + + self.view.required_size(req) + (2, 2) } fn wrap_draw(&self, printer: &Printer) {