diff --git a/examples/text/src/buffer.rs b/examples/text/src/buffer.rs index ec385ee0..180ecce3 100644 --- a/examples/text/src/buffer.rs +++ b/examples/text/src/buffer.rs @@ -37,15 +37,19 @@ pub struct TextBuffer<'a> { impl<'a> TextBuffer<'a> { pub fn new(font_matches: &'a FontMatches, text: &str, font_size: i32, line_width: i32) -> Self { + let mut text_lines: Vec = text.lines().map(String::from).collect(); + if text_lines.is_empty() { + text_lines.push(String::new()); + } let mut buffer = Self { font_matches, - text_lines: text.lines().map(String::from).collect(), + text_lines, shape_lines: Vec::new(), layout_lines: Vec::new(), font_size, line_width, cursor: TextCursor::default(), - redraw: true, + redraw: false, }; buffer.reshape(); buffer