commit c934c1d71b4602b025603380046824d9eafc456a parent a16315a65f38cceeffbb287c086581dfb3e47c82 Author: Benno Schulenberg <bensberg@telfort.nl> Date: Sun, 8 Mar 2020 16:10:33 +0100 justify: trim prefixed whitespace when justifying a marked region This fixes https://savannah.gnu.org/bugs/?56307. Bug existed since version 4.0, when the justifying of a marked region was introduced. Diffstat:
M | src/text.c | | | 15 | +++++++++++++++ |
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/text.c b/src/text.c @@ -1763,6 +1763,21 @@ void do_justify(bool full_justify) return; } + /* Recede over any preceding whitespace. This effectively snips + * trailing blanks from what will become the preceding paragraph. */ + while (start_x > 0 && is_blank_mbchar(&startline->data[start_x - 1])) + start_x--; + + /* Advance over any subsequent whitespace. */ + while (is_blank_mbchar(&endline->data[end_x])) + end_x++; + + /* Include preceding and subsequent whitespace into the marked region. */ + openfile->mark = startline; + openfile->mark_x = start_x; + openfile->current = endline; + openfile->current_x = end_x; + par_len = endline->lineno - startline->lineno + (end_x > 0 ? 1 : 0); /* Remember whether the end of the region was before the end-of-line. */