cut: concentrate the logic for clearing the cutbuffer mostly in one place
It should not be the task of the undo code to take care that the cutbuffer will be cleared at the right moments.master
parent
33d81fa1e6
commit
71f859377d
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue