diff --git a/src/cut.c b/src/cut.c index 4037d80c..bc458f39 100644 --- a/src/cut.c +++ b/src/cut.c @@ -125,12 +125,12 @@ void do_cut_text(bool copy_text, bool cut_till_eof) #endif size_t was_totsize = openfile->totsize; - /* If a chain of cuts was broken, empty the cutbuffer. */ - if (!keep_cutbuffer) { + /* If cuts were not continuous, or when cutting a region, clear the slate. */ + if (!keep_cutbuffer || openfile->mark || cut_till_eof) { free_filestruct(cutbuffer); cutbuffer = NULL; - /* Indicate that future cuts should add to the cutbuffer. */ - keep_cutbuffer = TRUE; + /* After a line cut, future line cuts should add to the cutbuffer. */ + keep_cutbuffer = !openfile->mark && !cut_till_eof; } #ifndef NANO_TINY diff --git a/src/nano.c b/src/nano.c index 79b54508..784953a3 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1759,7 +1759,6 @@ int do_input(bool allow_funcs) if (shortcut->func == do_cut_text_void #ifndef NANO_TINY || shortcut->func == do_copy_text - || shortcut->func == do_cut_till_eof #endif ) retain_cuts = TRUE; diff --git a/src/text.c b/src/text.c index 4592053b..e95c77ba 100644 --- a/src/text.c +++ b/src/text.c @@ -1395,10 +1395,8 @@ void add_undo(undo_type action) break; #endif case CUT_TO_EOF: - cutbuffer_reset(); break; case CUT: - cutbuffer_reset(); if (openfile->mark) { u->mark_begin_lineno = openfile->mark->lineno; u->mark_begin_x = openfile->mark_x;