From b81fb73c3751ecbda4983ed83333ea7a88c077fb Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 24 Feb 2018 20:59:44 -0800 Subject: [PATCH] Really avoid underflow with `apt` scrolling I thought I took care of this in 7c0536f9a36aca1d0a9af018b56dd435722cd31d, but I misunderstood how saturating_sub works. I still need to clamp it within range. --- term/src/csi.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/term/src/csi.rs b/term/src/csi.rs index 7f4585535..94c5784f8 100644 --- a/term/src/csi.rs +++ b/term/src/csi.rs @@ -369,8 +369,8 @@ impl<'a> CSIParser<'a> { &[top, bottom] => { self.advance_by(2, params); Some(CSIAction::SetScrollingRegion { - top: top.saturating_sub(1), - bottom: bottom.saturating_sub(1), + top: top.saturating_sub(1).max(0), + bottom: bottom.saturating_sub(1).max(0), }) } &[] => {