undo: move some special checking code to the one place that needs it
Only for BACK and DEL was the first call to update_undo() -- all other types of action would call add_undo() first, so for them the action in update_undo() would never be different, but the line number might have changed (like for ENTER and INSERT), so for them exceptions needed to be made, which was wasteful. This addresses https://savannah.gnu.org/bugs/?54728.master
parent
c545438a5f
commit
4c6ec6377f
18
src/text.c
18
src/text.c
|
@ -99,7 +99,13 @@ void do_deletion(undo_type action)
|
|||
openfile->current_x);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
update_undo(action);
|
||||
/* If the type of action changed or the cursor moved to a different
|
||||
* line, create a new undo item, otherwise update the existing item. */
|
||||
if (action != openfile->last_action ||
|
||||
openfile->current->lineno != openfile->current_undo->lineno)
|
||||
add_undo(action);
|
||||
else
|
||||
update_undo(action);
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
old_amount = number_of_chunks_in(openfile->current);
|
||||
|
@ -1481,16 +1487,6 @@ void update_undo(undo_type action)
|
|||
char *char_buf;
|
||||
int char_len;
|
||||
|
||||
/* If the action is different or the position changed, don't update the
|
||||
* current record but add a new one instead. */
|
||||
if (action != openfile->last_action ||
|
||||
(action != ENTER && action != CUT && action != INSERT &&
|
||||
action != COUPLE_END &&
|
||||
openfile->current->lineno != openfile->current_undo->lineno)) {
|
||||
add_undo(action);
|
||||
return;
|
||||
}
|
||||
|
||||
u->newsize = openfile->totsize;
|
||||
|
||||
switch (u->type) {
|
||||
|
|
Loading…
Reference in New Issue