Fixed bug in buffer drawing code.

It was causing the entire last line to be re-scanned to find the
cursor drawing position if the cursor was at the end of the buffer.
This was both slow and resulted in an incorrect position, since
all the rest of the drawing assumes line blocks.
This commit is contained in:
Nathan Vegdahl 2015-02-22 20:24:19 -08:00
parent ae26c5f873
commit c348f252bb

View File

@ -479,8 +479,7 @@ impl TermUI {
if at_cursor {
// Calculate the cell coordinates at which to draw the cursor
let line = self.editor.buffer.get_line(self.editor.buffer.line_count()-1);
let (_, pos_x) = editor.formatter.index_to_v2d(line.grapheme_iter(), line.grapheme_count());
let pos_x = editor.formatter.index_to_horizontal_v2d(&self.editor.buffer, self.editor.buffer.grapheme_count());
let px = pos_x as isize + screen_col - editor.view_pos.1 as isize;
let py = screen_line - 1;