From 2dd5f0f45d403fee11215eb515eff41168198e13 Mon Sep 17 00:00:00 2001 From: Josh Leverette Date: Fri, 6 Jan 2017 15:00:15 -0500 Subject: Handle invalid gotos more gracefully. --- src/term/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/term') diff --git a/src/term/mod.rs b/src/term/mod.rs index c93ec963..690c2f10 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -643,9 +643,10 @@ impl ansi::Handler for Term { #[inline] fn goto(&mut self, line: Line, col: Column) { + use std::cmp::min; debug_println!("goto: line={}, col={}", line, col); - self.cursor.line = line; - self.cursor.col = col; + self.cursor.line = min(line, self.grid.num_lines() - 1); + self.cursor.col = min(col, self.grid.num_cols() - 1); } #[inline] -- cgit v1.2.3-54-g00ecf