Fix crash when selecting previous paragraph at buffer begin

Fixes #3489

When there are multiple empty lines between a paragraph and the cursor
(C in the example below), <a-[>p skips over one of them. Prevent the
check for the extra newline from going out of bounds.

```
a paragraph

C	after <a-[>p, the first two lines will be selected
```
This commit is contained in:
Johannes Altmanninger 2020-05-17 13:55:54 +02:00
parent 08509cb408
commit fc63eef695
4 changed files with 5 additions and 1 deletions

View File

@ -560,7 +560,7 @@ select_paragraph(const Context& context, const Selection& selection,
BufferIterator first = buffer.iterator_at(selection.cursor());
if (not (flags & ObjectFlags::ToEnd) and first.coord() > BufferCoord{0,1} and
is_eol(*(first-1)) and is_eol(*(first-2)))
is_eol(*(first-1)) and first-1 != buffer.begin() and is_eol(*(first-2)))
--first;
else if ((flags & ObjectFlags::ToEnd) and
first != buffer.begin() and (first+1) != buffer.end() and

View File

@ -0,0 +1 @@
j<a-[>p

View File

@ -0,0 +1,2 @@

View File

@ -0,0 +1 @@
2.1,1.1