From 7acf3da3ca6b012d603e4cf7360abb4a3235daca Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 7 Jun 2015 23:17:23 +0100 Subject: [PATCH] Change select_to_eol implementation --- src/selectors.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/selectors.cc b/src/selectors.cc index 80a8c118..03227734 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -207,18 +207,18 @@ Selection select_to_reverse(const Buffer& buffer, const Selection& selection, Selection select_to_eol(const Buffer& buffer, const Selection& selection) { - Utf8Iterator begin = buffer.iterator_at(selection.cursor()); - Utf8Iterator end = begin; - skip_while(end, buffer.end(), [](Codepoint cur) { return not is_eol(cur); }); - return target_eol(utf8_range(begin, end != begin ? end-1 : end)); + ByteCoord begin = selection.cursor(); + LineCount line = begin.line; + ByteCoord end = utf8::previous(buffer.iterator_at({line, buffer[line].length() - 1}), + buffer.iterator_at(line)).coord(); + return target_eol({begin, end}); } Selection select_to_eol_reverse(const Buffer& buffer, const Selection& selection) { - Utf8Iterator begin = buffer.iterator_at(selection.cursor()); - Utf8Iterator end = begin - 1; - skip_while_reverse(end, buffer.begin(), [](Codepoint cur) { return not is_eol(cur); }); - return utf8_range(begin, end == buffer.begin() ? end : end+1); + ByteCoord begin = selection.cursor(); + ByteCoord end = begin.line; + return {begin, end}; } Selection select_number(const Buffer& buffer, const Selection& selection, ObjectFlags flags)