Index: src/nano.c =================================================================== --- src/nano.c (revision 5065) +++ src/nano.c (working copy) @@ -360,6 +360,9 @@ *file_bot = openfile->filebot; } + openfile->fileage->next = NULL; + free_filestruct(openfile->fileage); + /* Renumber starting with the line after the original * file_bot. */ if (file_bot_save->next != NULL) @@ -447,6 +450,7 @@ /* Put the top and bottom of the current filestruct at the top and * bottom of a copy of the passed buffer. */ + free_filestruct(openfile->fileage); openfile->fileage = copy_filestruct(somebuffer); openfile->filebot = openfile->fileage; while (openfile->filebot->next != NULL) Index: src/text.c =================================================================== --- src/text.c (revision 5065) +++ src/text.c (working copy) @@ -504,10 +504,12 @@ case CUT: undidmsg = _("text cut"); undo_cut(u); + f = fsfromline(u->lineno); break; case PASTE: undidmsg = _("text uncut"); undo_paste(u); + f = fsfromline(u->lineno); break; case ENTER: undidmsg = _("line break");