Properly handle empty last line
This commit is contained in:
parent
104da286b1
commit
ec3200625e
22
src/main.rs
22
src/main.rs
@ -233,21 +233,25 @@ impl FramebufferWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fbuf.update_screen();
|
||||||
|
|
||||||
let cursor_glyph = glyphs.last().unwrap();
|
let cursor_glyph = glyphs.last().unwrap();
|
||||||
|
|
||||||
self.cursor_top = cursor_glyph.y as usize - first_line_top_offset + self.next_line_y;
|
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;
|
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();
|
let last_line = self.layout.lines().unwrap().last().unwrap();
|
||||||
fbuf.update_screen();
|
let log_line_slice = if last_line.glyph_start == last_line.glyph_end {
|
||||||
|
""
|
||||||
let first_char_offset = glyphs[last_line.glyph_start].byte_offset;
|
} else {
|
||||||
let last_char_offset = glyphs[last_line.glyph_end -1].byte_offset;
|
let first_char_offset = glyphs[last_line.glyph_start].byte_offset;
|
||||||
let mut last_char_end = last_char_offset + 1;
|
let last_char_offset = glyphs[last_line.glyph_end-1].byte_offset;
|
||||||
while last_char_end < self.out_string.len() && !self.out_string.is_char_boundary(last_char_end) {
|
let mut last_char_end = last_char_offset + 1;
|
||||||
last_char_end += 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];
|
}
|
||||||
|
&self.out_string[first_char_offset..last_char_end]
|
||||||
|
};
|
||||||
|
|
||||||
let before_last_height = (last_line.baseline_y - last_line.max_ascent) as usize;
|
let before_last_height = (last_line.baseline_y - last_line.max_ascent) as usize;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user