Index: src/cut.c =================================================================== --- src/cut.c (revision 4966) +++ src/cut.c (working copy) @@ -248,7 +248,17 @@ * 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/nano.c =================================================================== --- src/nano.c (revision 4966) +++ src/nano.c (working copy) @@ -1573,8 +1573,6 @@ /* The input buffer. */ static size_t kbinput_len = 0; /* The length of the input buffer. */ - bool preserve = FALSE; - /* Preserve the contents of the cutbuffer? */ const sc *s; bool have_shortcut; @@ -1667,15 +1665,6 @@ } if (have_shortcut) { - /* If the function associated with this shortcut is - * cutting or copying text, remember this. */ - if (s->scfunc == do_cut_text_void -#ifndef NANO_TINY - || s->scfunc == do_copy_text || s->scfunc == do_cut_till_end -#endif - ) - preserve = TRUE; - if (s->scfunc != 0) { const subnfunc *f = sctofunc((sc *) s); if (ISSET(VIEW_MODE) && f && !f->viewok) @@ -1684,7 +1673,6 @@ #ifndef NANO_TINY if (s->scfunc == do_toggle_void) { do_toggle(s->toggle); - preserve = TRUE; } else #endif { @@ -1708,11 +1696,6 @@ } } - /* If we aren't cutting or copying text, and the key wasn't a toggle, - * blow away the text in the cutbuffer upon the next cutting action. */ - if (!preserve) - cutbuffer_reset(); - return input; } Index: src/text.c =================================================================== --- src/text.c (revision 4966) +++ src/text.c (working copy) @@ -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;