From 9078039326a7a2b5d7d78998171fe61ea3f72fe9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 5 Oct 2016 23:42:36 +0100 Subject: [PATCH] Fix select_to_previous_word with spaces at buffer start Fixes #844 --- src/selectors.hh | 3 +-- test/regression/844-prev-word-at-buffer-start/cmd | 1 + test/regression/844-prev-word-at-buffer-start/in | 1 + test/regression/844-prev-word-at-buffer-start/selections | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 test/regression/844-prev-word-at-buffer-start/cmd create mode 100644 test/regression/844-prev-word-at-buffer-start/in create mode 100644 test/regression/844-prev-word-at-buffer-start/selections diff --git a/src/selectors.hh b/src/selectors.hh index 462b188f..f9be9247 100644 --- a/src/selectors.hh +++ b/src/selectors.hh @@ -94,9 +94,8 @@ Selection select_to_previous_word(const Buffer& buffer, const Selection& selecti skip_while_reverse(begin, buffer.begin(), [](Codepoint c){ return is_eol(c); }); Utf8Iterator end = begin; - skip_while_reverse(end, buffer.begin(), is_horizontal_blank); - bool with_end = false; + bool with_end = skip_while_reverse(end, buffer.begin(), is_horizontal_blank); if (word_type == Word and is_punctuation(*end)) with_end = skip_while_reverse(end, buffer.begin(), is_punctuation); diff --git a/test/regression/844-prev-word-at-buffer-start/cmd b/test/regression/844-prev-word-at-buffer-start/cmd new file mode 100644 index 00000000..e0b3f1b0 --- /dev/null +++ b/test/regression/844-prev-word-at-buffer-start/cmd @@ -0,0 +1 @@ +bb diff --git a/test/regression/844-prev-word-at-buffer-start/in b/test/regression/844-prev-word-at-buffer-start/in new file mode 100644 index 00000000..ce10d429 --- /dev/null +++ b/test/regression/844-prev-word-at-buffer-start/in @@ -0,0 +1 @@ + %(word) diff --git a/test/regression/844-prev-word-at-buffer-start/selections b/test/regression/844-prev-word-at-buffer-start/selections new file mode 100644 index 00000000..1a4baf53 --- /dev/null +++ b/test/regression/844-prev-word-at-buffer-start/selections @@ -0,0 +1 @@ +