nano

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

commit 0f4bb64eaf98b54c601c86a19b2a5c3209c439cf
parent 45efe28f05461f1e4ce58e913b6e29a3f94aacc3
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri,  1 Jan 2021 19:39:07 +0100

undo: remove the added magic line when a replacement caused one

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

Bug existed since before version 2.2.4.

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

diff --git a/src/text.c b/src/text.c @@ -583,6 +583,8 @@ void do_undo(void) break; case REPLACE: undidmsg = _("replacement"); + if ((u->xflags & INCLUDED_LAST_LINE) && !ISSET(NO_NEWLINES)) + remove_magicline(); data = u->strdata; u->strdata = line->data; line->data = data; @@ -755,6 +757,8 @@ void do_redo(void) break; case REPLACE: redidmsg = _("replacement"); + if ((u->xflags & INCLUDED_LAST_LINE) && !ISSET(NO_NEWLINES)) + new_magicline(); data = u->strdata; u->strdata = line->data; line->data = data; @@ -1039,6 +1043,8 @@ void add_undo(undo_type action, const char *message) break; case REPLACE: u->strdata = copy_of(thisline->data); + if (thisline == openfile->filebot && u->strdata[0] != '\0') + u->xflags |= INCLUDED_LAST_LINE; break; #ifdef ENABLE_WRAPPING case SPLIT_BEGIN: