aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Wilm <jwilm@users.noreply.github.com>2017-01-07 17:16:50 -0800
committerGitHub <noreply@github.com>2017-01-07 17:16:50 -0800
commit3c2bfdc0fc59469d7f88a8c9104682480d016001 (patch)
tree7b552792d863553d92b36e5c0b5f6b9ea0ffb126
parent61389c1fcd236edbce36ef5d722970978175849c (diff)
parentfb56dcbad94b7606d67cd911ea2c8784bcd8a247 (diff)
downloadr-alacritty-3c2bfdc0fc59469d7f88a8c9104682480d016001.tar.gz
r-alacritty-3c2bfdc0fc59469d7f88a8c9104682480d016001.tar.bz2
r-alacritty-3c2bfdc0fc59469d7f88a8c9104682480d016001.zip
Merge pull request #220 from mbrumlow/resize_fix
Fixing resize crashes.
-rw-r--r--src/term/mod.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 73f9ad61..68fd8223 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -475,8 +475,8 @@ impl Term {
let old_cols = self.size_info.cols();
let old_lines = self.size_info.lines();
- let num_cols = size.cols();
- let num_lines = size.lines();
+ let mut num_cols = size.cols();
+ let mut num_lines = size.lines();
self.size_info = size;
@@ -484,6 +484,16 @@ impl Term {
return;
}
+ // Should not allow less than 1 col, causes all sorts of checks to be required.
+ if num_cols <= Column(1) {
+ num_cols = Column(2);
+ }
+
+ // Should not allow less than 1 line, causes all sorts of checks to be required.
+ if num_lines <= Line(1) {
+ num_lines = Line(2);
+ }
+
// Scroll up to keep cursor and as much context as possible in grid.
// This only runs when the lines decreases.
self.scroll_region = Line(0)..self.grid.num_lines();
@@ -513,10 +523,12 @@ impl Term {
self.tabs[0] = false;
- // Make sure bottom of terminal is clear
- let template = self.empty_cell;
- self.grid.clear_region((self.cursor.line).., |c| c.reset(&template));
- self.alt_grid.clear_region((self.cursor.line).., |c| c.reset(&template));
+ if num_lines > old_lines {
+ // Make sure bottom of terminal is clear
+ let template = self.empty_cell;
+ self.grid.clear_region((self.cursor.line + 1).., |c| c.reset(&template));
+ self.alt_grid.clear_region((self.cursor.line + 1).., |c| c.reset(&template));
+ }
// Reset scrolling region to new size
self.scroll_region = Line(0)..self.grid.num_lines();