diff --git a/src/text.c b/src/text.c index 17bdb226..74e5e607 100644 --- a/src/text.c +++ b/src/text.c @@ -2434,13 +2434,16 @@ void do_justify(bool full_justify) } #endif - /* Break the current line. */ - if (ISSET(JUSTIFY_TRIM)) { + /* When requested, trim trailing spaces. */ + if (ISSET(JUSTIFY_TRIM)) { while (break_pos > 0 && is_blank_mbchar(&openfile->current->data[break_pos - 1])) { break_pos--; + openfile->totsize--; } } + + /* Break the current line. */ null_at(&openfile->current->data, break_pos); /* Go to the next line. */