From e94735bbd375e623817841f1841e3900c91617df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 21 May 2024 03:50:54 +0900 Subject: [PATCH] tui: Port https://github.com/ratatui-org/ratatui/pull/1036 --- helix-tui/src/buffer.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs index 51a864f5f..6126c249c 100644 --- a/helix-tui/src/buffer.rs +++ b/helix-tui/src/buffer.rs @@ -130,22 +130,21 @@ pub struct Buffer { impl Buffer { /// Returns a Buffer with all cells set to the default one + #[must_use] pub fn empty(area: Rect) -> Buffer { - let cell: Cell = Default::default(); - Buffer::filled(area, &cell) + Buffer::filled(area, &Cell::default()) } /// Returns a Buffer with all cells initialized with the attributes of the given Cell + #[must_use] pub fn filled(area: Rect, cell: &Cell) -> Buffer { let size = area.area(); - let mut content = Vec::with_capacity(size); - for _ in 0..size { - content.push(cell.clone()); - } + let content = vec![cell.clone(); size]; Buffer { area, content } } /// Returns a Buffer containing the given lines + #[must_use] pub fn with_lines(lines: Vec) -> Buffer where S: AsRef,