diff --git a/src/main.rs b/src/main.rs index 0651975..37e60ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -233,21 +233,25 @@ impl FramebufferWriter { } } + fbuf.update_screen(); + let cursor_glyph = glyphs.last().unwrap(); self.cursor_top = cursor_glyph.y as usize - first_line_top_offset + self.next_line_y; self.cursor_bot = cursor_glyph.y as usize - first_line_top_offset + self.next_line_y + cursor_glyph.height; let last_line = self.layout.lines().unwrap().last().unwrap(); - fbuf.update_screen(); - - let first_char_offset = glyphs[last_line.glyph_start].byte_offset; - let last_char_offset = glyphs[last_line.glyph_end -1].byte_offset; - let mut last_char_end = last_char_offset + 1; - while last_char_end < self.out_string.len() && !self.out_string.is_char_boundary(last_char_end) { - last_char_end += 1; - } - let log_line_slice = &self.out_string[first_char_offset..last_char_end]; + let log_line_slice = if last_line.glyph_start == last_line.glyph_end { + "" + } else { + let first_char_offset = glyphs[last_line.glyph_start].byte_offset; + let last_char_offset = glyphs[last_line.glyph_end-1].byte_offset; + let mut last_char_end = last_char_offset + 1; + while last_char_end < self.out_string.len() && !self.out_string.is_char_boundary(last_char_end) { + last_char_end += 1; + } + &self.out_string[first_char_offset..last_char_end] + }; let before_last_height = (last_line.baseline_y - last_line.max_ascent) as usize;