aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/grid/mod.rs12
-rw-r--r--src/term/mod.rs12
2 files changed, 22 insertions, 2 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs
index 05fae373..6359a4ee 100644
--- a/src/grid/mod.rs
+++ b/src/grid/mod.rs
@@ -238,8 +238,11 @@ impl<T: Copy + Clone> Grid<T> {
self.raw.grow_visible_lines(new_line_count, Row::new(self.cols, template));
self.lines = new_line_count;
- // Add new lines to bottom
- self.scroll_up(&(Line(0)..new_line_count), lines_added, template);
+ // Move existing lines up if there is no scrollback to fill new lines
+ if lines_added.0 > self.scroll_limit {
+ let scroll_lines = lines_added - self.scroll_limit;
+ self.scroll_up(&(Line(0)..new_line_count), scroll_lines, template);
+ }
self.scroll_limit = self.scroll_limit.saturating_sub(*lines_added);
}
@@ -417,6 +420,11 @@ impl<T> Grid<T> {
self.scroll_limit = 0;
}
+ #[inline]
+ pub fn scroll_limit(&self) -> usize {
+ self.scroll_limit
+ }
+
/// Total number of lines in the buffer, this includes scrollback + visible lines
#[inline]
pub fn len(&self) -> usize {
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 1b78c39c..ff7a53e9 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -1144,6 +1144,18 @@ impl Term {
let lines = self.cursor_save_alt.point.line - num_lines + 1;
self.alt_grid.scroll_up(&(Line(0)..old_lines), lines, &self.cursor_save_alt.template);
}
+
+ // Move prompt down when growing if scrollback lines are available
+ if num_lines > old_lines {
+ if self.mode.contains(TermMode::ALT_SCREEN) {
+ let growage = min(num_lines - old_lines, Line(self.alt_grid.scroll_limit()));
+ self.cursor_save.point.line += growage;
+ } else {
+ let growage = min(num_lines - old_lines, Line(self.grid.scroll_limit()));
+ self.cursor.point.line += growage;
+ }
+ }
+
debug!("num_cols, num_lines = {}, {}", num_cols, num_lines);
// Resize grids to new size