mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-03 04:34:21 -05:00
Fixing resize crashes.
Most of the crashes on resize were due to columns and lines being set to zero. This causes all sorts of other checks within the code to ensure these values are greater than zero before running calculations. To avoid this we just need to ensure that lines and columns are some non zero value. This is seems to be what gnome terminal does. I have selected 2 lines and two columns for min terminal size for now.
This commit is contained in:
parent
61389c1fcd
commit
fb56dcbad9
1 changed files with 18 additions and 6 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue