From d52e545db3a9757325002f2a3ffd232e791f0093 Mon Sep 17 00:00:00 2001 From: Yan Date: Sat, 4 Nov 2017 05:37:31 +0100 Subject: [PATCH] Correct linefeed handling when scroll region set (#855) Linefeeds should only move the cursor down if it's before the end of the scroll region. The "out of bounds" panic was triggered by linefeeds going off the bottom of the screen when the scroll region end was above the cursor. Note: https://vt100.net/docs/vt102-ug/chapter5.html "Characters added outside the scrolling region do not cause the screen to scroll." --- src/term/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/term/mod.rs b/src/term/mod.rs index 7324d401..503d09ec 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -1452,7 +1452,9 @@ impl ansi::Handler for Term { if (self.cursor.point.line + 1) == self.scroll_region.end { self.scroll_up(Line(1)); } else { - self.cursor.point.line += 1; + if (self.cursor.point.line + 1) < self.scroll_region.end { + self.cursor.point.line += 1; + } } }