Commit 7e152f2a authored by David Lawrence Ramsey's avatar David Lawrence Ramsey Committed by Benno Schulenberg
Browse files

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.
No related merge requests found
Showing with 8 additions and 0 deletions
+8 -0
...@@ -670,6 +670,10 @@ void undo_cut(undo *u) ...@@ -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) ...@@ -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) ...@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment