From 532ae5a1a672eb225e5c0a72e6b4fbc978f5b6d7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 22 Jun 2016 19:56:40 +0100 Subject: [PATCH] Do not go backward to when selecting to end of line from the end of line Fixes #699 --- src/selectors.hh | 2 ++ test/regression/699-to-eol-from-eol/cmd | 1 + test/regression/699-to-eol-from-eol/in | 1 + test/regression/699-to-eol-from-eol/state | 1 + 4 files changed, 5 insertions(+) create mode 100644 test/regression/699-to-eol-from-eol/cmd create mode 100644 test/regression/699-to-eol-from-eol/in create mode 100644 test/regression/699-to-eol-from-eol/state diff --git a/src/selectors.hh b/src/selectors.hh index 6ac840b1..8982a00e 100644 --- a/src/selectors.hh +++ b/src/selectors.hh @@ -121,6 +121,8 @@ Selection select_to_line_end(const Buffer& buffer, const Selection& selection) LineCount line = begin.line; ByteCoord end = utf8::previous(buffer.iterator_at({line, buffer[line].length() - 1}), buffer.iterator_at(line)).coord(); + if (end < begin) // Do not go backward when cursor is on eol + end = begin; return target_eol({only_move ? end : begin, end}); } diff --git a/test/regression/699-to-eol-from-eol/cmd b/test/regression/699-to-eol-from-eol/cmd new file mode 100644 index 00000000..990c6c74 --- /dev/null +++ b/test/regression/699-to-eol-from-eol/cmd @@ -0,0 +1 @@ +x; diff --git a/test/regression/699-to-eol-from-eol/in b/test/regression/699-to-eol-from-eol/in new file mode 100644 index 00000000..2ef41c6c --- /dev/null +++ b/test/regression/699-to-eol-from-eol/in @@ -0,0 +1 @@ +my line diff --git a/test/regression/699-to-eol-from-eol/state b/test/regression/699-to-eol-from-eol/state new file mode 100644 index 00000000..360ce6bd --- /dev/null +++ b/test/regression/699-to-eol-from-eol/state @@ -0,0 +1 @@ +1.8,1.8