nano

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

commit 9410a55679df16420de1a9e5867791f0525a9ed5
parent 25ceefbd895f5493c7077d5b15893f5157e14ec9
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 24 Aug 2022 15:45:24 +0200

undo: make sure the current line is defined before it is referenced

After undoing an <Enter> or redoing a line join, it is likely that the
"eaten" and freed line was the current line.  In fact, goto_line_posx()
should not refer to it any more, but... accommodate for this and just
set openfile->current to a valid value before calling goto_line_posx().

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

Bug existed since version 6.3, commit eea3e1f0.

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

diff --git a/src/text.c b/src/text.c @@ -540,6 +540,7 @@ void do_undo(void) line->has_anchor |= line->next->has_anchor; unlink_node(line->next); renumber_from(line); + openfile->current = line; goto_line_posx(u->head_lineno, original_x); break; case BACK: @@ -746,6 +747,7 @@ void do_redo(void) strcat(line->data, u->strdata); unlink_node(line->next); renumber_from(line); + openfile->current = line; goto_line_posx(u->tail_lineno, u->tail_x); break; case REPLACE: