diff --git a/src/selectors.cc b/src/selectors.cc index 2c657b80..cf631e72 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -420,6 +420,12 @@ select_to_reverse(const Context& context, const Selection& selection, Codepoint c, int count, bool inclusive) { auto& buffer = context.buffer(); + + // if we are selecting backwards from the beginning of the buffer, + // there is nothing more that can be selected. + if (selection.cursor() == buffer.begin()) + return {}; + Utf8Iterator begin{buffer.iterator_at(selection.cursor()), buffer}; Utf8Iterator end = begin; do diff --git a/test/regression/4471-crash-on-alt-t-with-one-char-file/cmd b/test/regression/4471-crash-on-alt-t-with-one-char-file/cmd new file mode 100644 index 00000000..ecd63ea5 --- /dev/null +++ b/test/regression/4471-crash-on-alt-t-with-one-char-file/cmd @@ -0,0 +1 @@ + diff --git a/test/regression/4471-crash-on-alt-t-with-one-char-file/in b/test/regression/4471-crash-on-alt-t-with-one-char-file/in new file mode 100644 index 00000000..e69de29b