From 12d3b64a1b0e156a35c6ddce93ea7d5472788754 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 5 Jun 2013 19:25:51 +0200 Subject: [PATCH] avoid_eol: use direct line access --- src/editor.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/editor.cc b/src/editor.cc index ae1008719..20e6f9df1 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -23,8 +23,9 @@ Editor::Editor(Buffer& buffer) static void avoid_eol(const Buffer& buffer, BufferCoord& coord) { const auto column = coord.column; - if (column != 0 and column == buffer[coord.line].length() - 1) - coord = buffer.char_prev(coord); + const auto& line = buffer[coord.line]; + if (column != 0 and column == line.length() - 1) + coord.column = line.byte_count_to(line.char_length() - 2); } static void avoid_eol(const Buffer& buffer, Range& sel)