diff --git a/src/nano.c b/src/nano.c index 74d56e46..09fe2df6 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1656,6 +1656,15 @@ void inject(char *burst, size_t count) if (burst[index] == '\0') burst[index] = '\n'; +#ifndef NANO_TINY + /* 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->mark_begin_lineno != openfile->current->lineno || + openfile->current_undo->mark_begin_x != openfile->current_x) + add_undo(ADD, NULL); +#endif + charlen = char_length(burst + index); /* Make room for the new character and copy it into the line. */ @@ -1674,13 +1683,6 @@ void inject(char *burst, size_t count) set_modified(); #ifndef NANO_TINY - /* 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->mark_begin_lineno != openfile->current->lineno || - openfile->current_undo->mark_begin_x != openfile->current_x) - add_undo(ADD, NULL); - /* Note that current_x has not yet been incremented. */ if (openfile->current == openfile->mark && openfile->current_x < openfile->mark_x) diff --git a/src/text.c b/src/text.c index 2c67a7cf..7236ea42 100644 --- a/src/text.c +++ b/src/text.c @@ -1159,7 +1159,6 @@ void add_undo(undo_type action, const char *message) /* If a new magic line will be added, an undo should remove it. */ if (openfile->current == openfile->filebot) u->xflags |= WAS_FINAL_LINE; - u->wassize--; break; case ENTER: break;