Handle invalid gotos more gracefully.

This commit is contained in:
Josh Leverette committed 2017-01-06 15:00:15 -05:00
1 parent 7d07b5a165
commit 2dd5f0f45d
1 file changed
+3 -2
+3 -2
View File
@@ -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]