Index: src/proto.h =================================================================== --- src/proto.h (revisión: 4974) +++ src/proto.h (copia de trabajo) @@ -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 (revisión: 4976) +++ src/text.c (copia de trabajo) @@ -854,7 +854,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; Index: src/cut.c =================================================================== --- src/cut.c (revisión: 4974) +++ src/cut.c (copia de trabajo) @@ -37,6 +37,12 @@ keep_cutbuffer = FALSE; } +/* Returns the status of the 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 +254,15 @@ * back into the filestruct afterward. */ void do_copy_text(void) { + static struct filestruct *next_contiguous_line = NULL; + bool mark_set = openfile->mark_set; + + if (mark_set || openfile->current != next_contiguous_line) + cutbuffer_reset(); + do_cut_text(TRUE, FALSE, FALSE); + + next_contiguous_line = (mark_set ? NULL : openfile->current); } /* Cut from the current cursor position to the end of the file. */