From 28716ec058768bdc4fa13b0a9667604e6f307c4c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 1 Mar 2018 15:32:26 +1100 Subject: [PATCH] Change x behaviour to select full line first even if on EOL x will always first select current line fully, and only then select next line. --- src/selectors.cc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/selectors.cc b/src/selectors.cc index 16518279e..a53bbafaa 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -173,17 +173,13 @@ Optional select_line(const Context& context, const Selection& selection) { auto& buffer = context.buffer(); - Utf8Iterator first{buffer.iterator_at(selection.cursor()), buffer}; - if (*first == '\n' and first + 1 != buffer.end()) - ++first; - - while (first != buffer.begin() and *(first - 1) != '\n') - --first; - - Utf8Iterator last = first; - while (last + 1 != buffer.end() and *last != '\n') - ++last; - return target_eol(utf8_range(first, last)); + auto line = selection.cursor().line; + // Next line if line fully selected + if (selection.anchor() <= BufferCoord{line, 0_byte} and + selection.cursor() == BufferCoord{line, buffer[line].length() - 1} and + line != buffer.line_count() - 1) + ++line; + return target_eol({{line, 0_byte}, {line, buffer[line].length() - 1}}); } template