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:
parent
08509cb408
commit
fc63eef695
|
@ -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
|
||||
|
|
1
test/regression/3489-crash-on-paragraph-begin/cmd
Normal file
1
test/regression/3489-crash-on-paragraph-begin/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
j<a-[>p
|
2
test/regression/3489-crash-on-paragraph-begin/in
Normal file
2
test/regression/3489-crash-on-paragraph-begin/in
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
|
|
@ -0,0 +1 @@
|
|||
2.1,1.1
|
Loading…
Reference in New Issue
Block a user