undo: move another piece of checking to the two places that need it
And in the bargain get rid of a function that is used just once.master
parent
efa323ec88
commit
8d0b7a490d
13
src/cut.c
13
src/cut.c
|
@ -33,12 +33,6 @@ void cutbuffer_reset(void)
|
|||
keep_cutbuffer = FALSE;
|
||||
}
|
||||
|
||||
/* Return the status of cutbuffer preservation. */
|
||||
inline bool keeping_cutbuffer(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
|
||||
|
@ -193,7 +187,12 @@ void do_cut_text(bool copy_text, bool marked, bool cut_till_eof)
|
|||
void do_cut_text_void(void)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
add_undo(CUT);
|
||||
/* Only add a new undo item when the current item is not a CUT or when
|
||||
* the current cut is not contiguous with the previous cutting. */
|
||||
if (openfile->last_action != CUT || openfile->current_undo == NULL ||
|
||||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
|
||||
!keep_cutbuffer)
|
||||
add_undo(CUT);
|
||||
do_cut_text(FALSE, openfile->mark, FALSE);
|
||||
update_undo(CUT);
|
||||
#else
|
||||
|
|
|
@ -1885,7 +1885,12 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
|||
set_modified();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(ADD);
|
||||
/* Only add a new undo item when the current item is not an ADD or when
|
||||
* the current typing is not contiguous with the previous typing. */
|
||||
if (openfile->last_action != ADD || openfile->current_undo == NULL ||
|
||||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
|
||||
openfile->current_undo->mark_begin_x != openfile->current_x)
|
||||
add_undo(ADD);
|
||||
|
||||
/* Note that current_x has not yet been incremented. */
|
||||
if (openfile->current == openfile->mark &&
|
||||
|
|
|
@ -251,7 +251,6 @@ void precalc_multicolorinfo(void);
|
|||
|
||||
/* Most functions in cut.c. */
|
||||
void cutbuffer_reset(void);
|
||||
bool keeping_cutbuffer(void);
|
||||
#ifndef NANO_TINY
|
||||
void cut_marked(bool *right_side_up);
|
||||
#endif
|
||||
|
|
|
@ -1319,14 +1319,6 @@ void add_undo(undo_type action)
|
|||
undo *u = openfile->current_undo;
|
||||
/* The thing we did previously. */
|
||||
|
||||
/* When doing contiguous adds or cuts, don't add a new undo item, but
|
||||
* let a later update call update the existing item. */
|
||||
if (u != NULL && action == openfile->last_action && action == u->type &&
|
||||
openfile->current->lineno == u->mark_begin_lineno &&
|
||||
((action == ADD && u->mark_begin_x == openfile->current_x) ||
|
||||
(action == CUT && keeping_cutbuffer())))
|
||||
return;
|
||||
|
||||
/* Blow away newer undo items if we add somewhere in the middle. */
|
||||
discard_until(u, openfile, TRUE);
|
||||
|
||||
|
|
Loading…
Reference in New Issue