undo: when undoing a paste or an insertion, remove an added magic line
When something is pasted or inserted onto the final, empty line of a buffer, an automatic new magic line is created after it, when needed. When this paste or insertion is undone, the added magic line should also be removed again. This fixes https://savannah.gnu.org/bugs/?57808. Bug existed since the undo capabilities were added, since before version 2.3.0.master
parent
68ca1732b8
commit
a0506a15ee
15
src/text.c
15
src/text.c
|
@ -481,9 +481,10 @@ void undo_cut(undostruct *u)
|
||||||
|
|
||||||
copy_from_buffer(u->cutbuffer);
|
copy_from_buffer(u->cutbuffer);
|
||||||
|
|
||||||
/* If the final line was originally cut, remove the extra magic line. */
|
/* If originally the last line was cut too, remove an extra magic line. */
|
||||||
if ((u->xflags & WAS_FINAL_LINE) && !ISSET(NO_NEWLINES) &&
|
if ((u->xflags & WAS_FINAL_LINE) && !ISSET(NO_NEWLINES) &&
|
||||||
openfile->current != openfile->filebot)
|
openfile->filebot != openfile->current &&
|
||||||
|
openfile->filebot->prev->data[0] == '\0')
|
||||||
remove_magicline();
|
remove_magicline();
|
||||||
|
|
||||||
if (!(u->xflags & WAS_MARKED_FORWARD) && u->type != PASTE)
|
if (!(u->xflags & WAS_MARKED_FORWARD) && u->type != PASTE)
|
||||||
|
@ -618,6 +619,9 @@ void do_undo(void)
|
||||||
case PASTE:
|
case PASTE:
|
||||||
undidmsg = _("paste");
|
undidmsg = _("paste");
|
||||||
undo_paste(u);
|
undo_paste(u);
|
||||||
|
if ((u->xflags & WAS_FINAL_LINE) && !ISSET(NO_NEWLINES) &&
|
||||||
|
openfile->filebot != openfile->current)
|
||||||
|
remove_magicline();
|
||||||
break;
|
break;
|
||||||
case INSERT:
|
case INSERT:
|
||||||
undidmsg = _("insertion");
|
undidmsg = _("insertion");
|
||||||
|
@ -629,6 +633,9 @@ void do_undo(void)
|
||||||
cut_marked(NULL);
|
cut_marked(NULL);
|
||||||
u->cutbuffer = cutbuffer;
|
u->cutbuffer = cutbuffer;
|
||||||
cutbuffer = oldcutbuffer;
|
cutbuffer = oldcutbuffer;
|
||||||
|
if ((u->xflags & WAS_FINAL_LINE) && !ISSET(NO_NEWLINES) &&
|
||||||
|
openfile->filebot != openfile->current)
|
||||||
|
remove_magicline();
|
||||||
break;
|
break;
|
||||||
case COUPLE_BEGIN:
|
case COUPLE_BEGIN:
|
||||||
undidmsg = u->strdata;
|
undidmsg = u->strdata;
|
||||||
|
@ -1216,10 +1223,14 @@ void add_undo(undo_type action, const char *message)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PASTE:
|
case PASTE:
|
||||||
|
if (openfile->current == openfile->filebot)
|
||||||
|
u->xflags |= WAS_FINAL_LINE;
|
||||||
u->cutbuffer = copy_buffer(cutbuffer);
|
u->cutbuffer = copy_buffer(cutbuffer);
|
||||||
u->lineno += cutbottom->lineno - cutbuffer->lineno;
|
u->lineno += cutbottom->lineno - cutbuffer->lineno;
|
||||||
break;
|
break;
|
||||||
case INSERT:
|
case INSERT:
|
||||||
|
if (openfile->current == openfile->filebot)
|
||||||
|
u->xflags |= WAS_FINAL_LINE;
|
||||||
break;
|
break;
|
||||||
case COUPLE_BEGIN:
|
case COUPLE_BEGIN:
|
||||||
u->mark_begin_lineno = openfile->current_y;
|
u->mark_begin_lineno = openfile->current_y;
|
||||||
|
|
Loading…
Reference in New Issue