From 0f4bb64eaf98b54c601c86a19b2a5c3209c439cf Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 1 Jan 2021 19:39:07 +0100 Subject: [PATCH] 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. --- src/text.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/text.c b/src/text.c index c742171e..ffebb4c9 100644 --- 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: