summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJosh Leverette <josh.leverette@utiliflex.com>2017-01-06 15:00:15 -0500
committerJosh Leverette <josh.leverette@utiliflex.com>2017-01-06 15:00:15 -0500
commit2dd5f0f45d403fee11215eb515eff41168198e13 (patch)
tree77c7ae5e139076c2df2ed8c61ee413a216ed7fe9 /src
parent7d07b5a1655dc9d1cda62f1dd3005b966c0fa76a (diff)
Handle invalid gotos more gracefully.
Diffstat (limited to 'src')
-rw-r--r--src/term/mod.rs5
1 files changed, 3 insertions, 2 deletions
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]