nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 93c8e316a8f4d7b507c3c016506dccee014846b5
parent 80bea3eb9b99e59b770b7ad27730194bc2548c24
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Sun, 26 Aug 2018 12:54:56 -0500

justify: verify being in a paragraph before trying to find its beginning

If find_paragraph() detects that we're not in a paragraph, it moves
forward a paragraph and then backward to that paragraph's beginning.
Make it check whether we're in a paragraph before moving backward
(since there might not *be* any more paragraphs), to prevent going
forth-and-back and never reaching the end of the buffer.

This fixes https://savannah.gnu.org/bugs/?54573.

Diffstat:
Msrc/text.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -2148,9 +2148,9 @@ bool find_paragraph(size_t *const quote, size_t *const par) } } - /* If the current line isn't the first line of the paragraph, move + /* If the current line is in a paragraph and isn't its first line, move * back to the first line of the paragraph. */ - if (!begpar(openfile->current, 0)) + if (inpar(openfile->current) && !begpar(openfile->current, 0)) do_para_begin(FALSE); /* Now current is the first line of the paragraph. Set quote_len to