From fafde8655b78b3a172f4b29ed9ead34649da6eb1 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 19 Sep 2016 09:20:55 +0100 Subject: [PATCH] Fix select_to_reverse to correctly handle the first character of the buffer Fixes #809 --- src/selectors.cc | 4 ++-- test/regression/809-alt-f-t-to-first-char/cmd | 1 + test/regression/809-alt-f-t-to-first-char/in | 1 + test/regression/809-alt-f-t-to-first-char/selections | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 test/regression/809-alt-f-t-to-first-char/cmd create mode 100644 test/regression/809-alt-f-t-to-first-char/in create mode 100644 test/regression/809-alt-f-t-to-first-char/selections diff --git a/src/selectors.cc b/src/selectors.cc index d683ce98..dc6edc98 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -229,8 +229,8 @@ Selection select_to_reverse(const Buffer& buffer, const Selection& selection, do { --end; - skip_while_reverse(end, buffer.begin(), [c](Codepoint cur) { return cur != c; }); - if (end == buffer.begin()) + if (skip_while_reverse(end, buffer.begin(), + [c](Codepoint cur) { return cur != c; })) return selection; } while (--count > 0); diff --git a/test/regression/809-alt-f-t-to-first-char/cmd b/test/regression/809-alt-f-t-to-first-char/cmd new file mode 100644 index 00000000..a3aa4304 --- /dev/null +++ b/test/regression/809-alt-f-t-to-first-char/cmd @@ -0,0 +1 @@ +f diff --git a/test/regression/809-alt-f-t-to-first-char/in b/test/regression/809-alt-f-t-to-first-char/in new file mode 100644 index 00000000..666200cb --- /dev/null +++ b/test/regression/809-alt-f-t-to-first-char/in @@ -0,0 +1 @@ +fooba%(r) diff --git a/test/regression/809-alt-f-t-to-first-char/selections b/test/regression/809-alt-f-t-to-first-char/selections new file mode 100644 index 00000000..323fae03 --- /dev/null +++ b/test/regression/809-alt-f-t-to-first-char/selections @@ -0,0 +1 @@ +foobar