Index: src/cut.c =================================================================== --- src/cut.c (revision 4966) +++ src/cut.c (working copy) @@ -37,6 +37,11 @@ keep_cutbuffer = FALSE; } +/* return status of cutbuffer. */ +inline bool is_cutbuffer_reset(void) +{ + return !keep_cutbuffer; +} /* If we aren't on the last line of the file, move all the text of the * current line, plus the newline at the end, into the cutbuffer. If we * are, move all of the text of the current line into the cutbuffer. In @@ -248,7 +253,18 @@ * back into the filestruct afterward. */ void do_copy_text(void) { + static struct filestruct * next_contiguous_line = 0; + bool mark_set = openfile->mark_set; + if(mark_set || openfile->current != next_contiguous_line) + cutbuffer_reset(); + do_cut_text(TRUE, FALSE, FALSE); + + if(!mark_set) + next_contiguous_line = openfile->current; + else + next_contiguous_line = 0; + } /* Cut from the current cursor position to the end of the file. */ Index: src/proto.h =================================================================== --- src/proto.h (revision 4966) +++ src/proto.h (working copy) @@ -249,6 +249,7 @@ /* All functions in cut.c. */ void cutbuffer_reset(void); +bool is_cutbuffer_reset(void); void cut_line(void); #ifndef NANO_TINY void cut_marked(void); Index: src/text.c =================================================================== --- src/text.c (revision 4966) +++ src/text.c (working copy) @@ -858,7 +858,7 @@ * on the same lineno, we need to abort here. */ u = fs->current_undo; if (u && u->mark_begin_lineno == fs->current->lineno && - ((current_action == CUT && u->type == CUT && !u->mark_set) || + ((!is_cutbuffer_reset() && current_action == CUT && u->type == CUT && !u->mark_set) || (current_action == ADD && u->type == ADD && u->mark_begin_x == fs->current_x))) return; @@ -945,6 +945,7 @@ case CUT_EOF: u->to_end = TRUE; case CUT: + cutbuffer_reset(); u->mark_set = openfile->mark_set; if (u->mark_set) { u->mark_begin_lineno = openfile->mark_begin->lineno;