undo: when undoing a cut, remove also the magicline if it added one

Reuse the WAS_FINAL_LINE flag to signal a cut that added a magicline,
for both a marked cut and cut-to-eof.

This fixes https://savannah.gnu.org/bugs/?55305.
master
David Lawrence Ramsey 2018-12-27 16:09:19 -06:00 committed by Benno Schulenberg
parent 8854ddb728
commit 7e152f2a48
1 changed files with 8 additions and 0 deletions

View File

@ -670,6 +670,10 @@ void undo_cut(undo *u)
copy_from_buffer(u->cutbuffer); copy_from_buffer(u->cutbuffer);
/* If the final line was originally cut, remove the extra magicline. */
if ((u->xflags & WAS_FINAL_LINE) && !ISSET(NO_NEWLINES))
remove_magicline();
if (!(u->xflags & WAS_MARKED_FORWARD) && u->type != PASTE) if (!(u->xflags & WAS_MARKED_FORWARD) && u->type != PASTE)
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x); goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
} }
@ -1414,6 +1418,7 @@ void add_undo(undo_type action)
break; break;
#endif #endif
case CUT_TO_EOF: case CUT_TO_EOF:
u->xflags |= WAS_FINAL_LINE;
break; break;
case ZAP: case ZAP:
case CUT: case CUT:
@ -1421,6 +1426,9 @@ void add_undo(undo_type action)
u->mark_begin_lineno = openfile->mark->lineno; u->mark_begin_lineno = openfile->mark->lineno;
u->mark_begin_x = openfile->mark_x; u->mark_begin_x = openfile->mark_x;
u->xflags |= MARK_WAS_SET; u->xflags |= MARK_WAS_SET;
if (openfile->current == openfile->filebot ||
openfile->mark == openfile->filebot)
u->xflags |= WAS_FINAL_LINE;
} else if (!ISSET(CUT_FROM_CURSOR)) { } else if (!ISSET(CUT_FROM_CURSOR)) {
/* The entire line is being cut regardless of the cursor position. */ /* The entire line is being cut regardless of the cursor position. */
u->begin = 0; u->begin = 0;