justify: set `x = 0` for the undo item, for when using --cutfromcursor

When --cutfromcursor is active, 'current_x' needs to be set to zero when
doing a justification, so that the correct starting position gets stored
in the undo item.  (Without --cutfromcursor, the value of 'current_x'
does not matter.)

This fixes https://savannah.gnu.org/bugs/?65317.
The issue was indirectly reported by `correctmost`.

Bug existed in this form since version 5.0, commit ae5a4ece.

Between versions 4.0 and 5.0, nano would not eat a line but would
instead crash when undoing a justification that was done with the
cursor away from the left edge.
This commit is contained in:
Benno Schulenberg 2024-02-15 16:53:49 +01:00
parent 2c42aa3181
commit 24393c6563
1 changed files with 2 additions and 1 deletions

View File

@ -1871,7 +1871,8 @@ void justify_text(bool whole_buffer)
#endif
refresh_needed = TRUE;
return;
}
} else
openfile->current_x = 0;
/* Set the starting point of the paragraph. */
startline = openfile->current;