From 2011eec9f2cb2d7f1a84dce14bec522d0e71e987 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 28 Jan 2018 19:30:07 -0800 Subject: [PATCH] clamp cursor y position when moving the cursor --- src/term/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/term/mod.rs b/src/term/mod.rs index 835fb1853..782cd47a6 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -456,8 +456,9 @@ impl TerminalState { /// top left of the visible screen. /// TODO: DEC origin mode impacts the interpreation of these fn set_cursor_pos(&mut self, x: usize, y: usize) { + let rows = self.screen().physical_rows; self.cursor_x = x; - self.cursor_y = y; + self.cursor_y = y.min(rows-1); self.state_changed = true; }