Handle invalid gotos more gracefully.
This commit is contained in:
parent
7d07b5a165
commit
2dd5f0f45d
|
@ -643,9 +643,10 @@ impl ansi::Handler for Term {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn goto(&mut self, line: Line, col: Column) {
|
fn goto(&mut self, line: Line, col: Column) {
|
||||||
|
use std::cmp::min;
|
||||||
debug_println!("goto: line={}, col={}", line, col);
|
debug_println!("goto: line={}, col={}", line, col);
|
||||||
self.cursor.line = line;
|
self.cursor.line = min(line, self.grid.num_lines() - 1);
|
||||||
self.cursor.col = col;
|
self.cursor.col = min(col, self.grid.num_cols() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Reference in New Issue