diff --git a/wezterm-gui/src/renderstate.rs b/wezterm-gui/src/renderstate.rs index 4a6fb204a..219d707f8 100644 --- a/wezterm-gui/src/renderstate.rs +++ b/wezterm-gui/src/renderstate.rs @@ -308,16 +308,18 @@ impl<'a> QuadAllocator for MappedQuads<'a> { fn extend_with(&mut self, vertices: &[Vertex]) { let idx = *self.next; + let len = vertices.len(); + // idx and next are number of quads, so divide by number of vertices - *self.next += vertices.len() / VERTICES_PER_CELL; + *self.next += len / VERTICES_PER_CELL; // Only copy in if there is enough room. // We'll detect the out of space condition at the end of // the render pass. let idx = idx * VERTICES_PER_CELL; - let len = self.capacity * VERTICES_PER_CELL; - if idx + vertices.len() < len { + let capacity = self.capacity * VERTICES_PER_CELL; + if idx + len <= capacity { self.mapping - .slice_mut(idx..idx + vertices.len()) + .slice_mut(idx..idx + len) .copy_from_slice(vertices); } }