aboutsummaryrefslogtreecommitdiff
path: root/src/grid/storage.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grid/storage.rs')
-rw-r--r--src/grid/storage.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/grid/storage.rs b/src/grid/storage.rs
index b620b9c0..cc32d6d1 100644
--- a/src/grid/storage.rs
+++ b/src/grid/storage.rs
@@ -48,6 +48,17 @@ impl<T> Storage<T> {
}
pub fn set_visible_lines(&mut self, next: Line) {
+ // Change capacity to fit scrollback + screen size
+ if next > self.visible_lines + 1 {
+ self.inner.reserve_exact((next - (self.visible_lines + 1)).0);
+ } else if next < self.visible_lines + 1 {
+ let shrinkage = (self.visible_lines + 1 - next).0;
+ let new_size = self.inner.capacity() - shrinkage;
+ self.inner.truncate(new_size);
+ self.inner.shrink_to_fit();
+ }
+
+ // Update visible lines
self.visible_lines = next - 1;
}