From c348f252bbc443a4cf40569bac608422719055e1 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 22 Feb 2015 20:24:19 -0800 Subject: [PATCH] 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. --- src/term_ui/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/term_ui/mod.rs b/src/term_ui/mod.rs index 3a8be37..ead062c 100644 --- a/src/term_ui/mod.rs +++ b/src/term_ui/mod.rs @@ -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;