justify: do not crash when the user attempts to justify an empty region

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

Bug existed since version 4.0, since the justifying
of a marked region was introduced.
master
Benno Schulenberg 2020-03-05 16:57:16 +01:00
parent 2bc5c1987c
commit 2d05ce37c6
1 changed files with 6 additions and 0 deletions

View File

@ -1930,6 +1930,12 @@ void do_justify(bool full_justify)
get_region((const linestruct **)&first_par_line, &top_x,
(const linestruct **)&last_par_line, &bot_x, &right_side_up);
/* When the marked region is empty, do nothing. */
if (first_par_line == last_par_line && top_x == bot_x) {
statusline(NOTICE, _("Nothing changed"));
return;
}
/* Save the starting point of the marked region. */
was_top_lineno = first_par_line->lineno;
was_top_x = top_x;