diff --git a/src/xwin.rs b/src/xwin.rs index e163b90b1..a2714b4f1 100644 --- a/src/xwin.rs +++ b/src/xwin.rs @@ -552,8 +552,8 @@ impl<'a> TerminalWindow<'a> { let mut verts = Vec::new(); let mut indices = Vec::new(); - let num_cols = ((width + 1.0) / cell_width).floor() as usize; - let num_rows = ((height + 1.0) / cell_height).floor() as usize; + let num_cols = (width as usize + 1) / cell_width as usize; + let num_rows = (height as usize + 1) / cell_height as usize; for y in 0..num_rows { for x in 0..num_cols { diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index a3a2023b4..17c914b82 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -650,6 +650,11 @@ impl TerminalState { let selection = self.selection_range.map(|r| r.normalize()); for (i, mut line) in screen.lines.iter().skip(len - height).enumerate() { + if i >= height { + // When scrolling back, make sure we don't emit lines that + // are below the bottom of the viewport + break; + } if line.is_dirty() { let selrange = match selection { None => 0..0,