nano

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

commit 190221c91cbf1ce67bf4fbb509c7c1258179b259
parent 77d74b5d811f6507a69e90cff77a903073c733da
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu, 15 Feb 2024 16:53:49 +0100

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.

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

diff --git a/src/text.c b/src/text.c @@ -1851,7 +1851,6 @@ void justify_text(bool whole_buffer) * in a paragraph but not at its beginning, move back to its first line. */ if (whole_buffer) { openfile->current = openfile->filetop; - openfile->current_x = 0; } else if (inpar(openfile->current) && !begpar(openfile->current, 0)) do_para_begin(&openfile->current); @@ -1866,7 +1865,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;