nano

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

commit 01477d3b81a918cf711fedafd4c713199b9bba76
parent ebf9279f95f690dcba98babcc8bc2ecd99d48cfa
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 11 Mar 2020 13:46:46 +0100

justify: never break a line in leading whitespace

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

The bug was old -- it existed since at least version 2.0.6.

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

diff --git a/src/text.c b/src/text.c @@ -1367,6 +1367,13 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl) int charlen = 0; /* The length of the current character, in bytes. */ + /* Skip over leading whitespace, where a line should never be broken. */ + while (*line != '\0' && is_blank_mbchar(line)) { + charlen = advance_over(line, &column); + line += charlen; + index += charlen; + } + /* Find the last blank that does not overshoot the target column. */ while (*line != '\0' && ((ssize_t)column <= goal)) { if (is_blank_mbchar(line))