aboutsummaryrefslogtreecommitdiff
path: root/src/grid/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grid/mod.rs')
-rw-r--r--src/grid/mod.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs
index 535f6cc6..949a5ed5 100644
--- a/src/grid/mod.rs
+++ b/src/grid/mod.rs
@@ -100,12 +100,6 @@ pub struct GridIterator<'a, T: 'a> {
/// Current position of the iterator within the grid.
pub cur: Point<usize>,
-
- /// Bottom of screen (buffer)
- bot: usize,
-
- /// Top of screen (buffer)
- top: usize,
}
pub enum Scroll {
@@ -357,7 +351,10 @@ impl<T: Copy + Clone> Grid<T> {
if region.start == Line(0) {
// Update display offset when not pinned to active area
if self.display_offset != 0 {
- self.display_offset += *positions;
+ self.display_offset = min(
+ self.display_offset + *positions,
+ self.len() - self.num_lines().0,
+ );
}
self.increase_scroll_limit(*positions);
@@ -433,8 +430,6 @@ impl<T> Grid<T> {
GridIterator {
grid: self,
cur: point,
- bot: self.display_offset,
- top: self.display_offset + *self.num_lines() - 1,
}
}
@@ -459,7 +454,7 @@ impl<'a, T> Iterator for GridIterator<'a, T> {
fn next(&mut self) -> Option<Self::Item> {
let last_col = self.grid.num_cols() - Column(1);
match self.cur {
- Point { line, col } if (line == self.bot) && (col == last_col) => None,
+ Point { line, col } if line == 0 && col == last_col => None,
Point { col, .. } if
(col == last_col) => {
self.cur.line -= 1;
@@ -479,7 +474,7 @@ impl<'a, T> BidirectionalIterator for GridIterator<'a, T> {
let num_cols = self.grid.num_cols();
match self.cur {
- Point { line, col: Column(0) } if line == self.top => None,
+ Point { line, col: Column(0) } if line == self.grid.len() - 1 => None,
Point { col: Column(0), .. } => {
self.cur.line += 1;
self.cur.col = num_cols - Column(1);