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.
This commit is contained in:
Benno Schulenberg 2021-01-01 19:39:07 +01:00
parent 45efe28f05
commit 0f4bb64eaf

View File

@ -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: