From: Benno Schulenberg Date: Mon, 6 Jul 2015 18:48:15 +0000 (+0000) Subject: Moving the check for a Delete at the end-of-file to a less frequently X-Git-Tag: v2.5.0~178 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=8f5fa24e517161c6b4bb8343c9bddcbaf7444f11;p=nano.git Moving the check for a Delete at the end-of-file to a less frequently travelled code path. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5284 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 5c73b25b..c4c505fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,11 @@ -2015-06-28 Benno Schulenberg +2015-07-06 Benno Schulenberg * src/global.c (add_to_sclist), src/help.c (help_init), src/nano.h, src/rcfile.c (parse_binding): When defining the toggles, give each of them a sequence number, so that, when they are rebound, they can still be listed in the original order in the help text. * src/text.c (do_undo): Make it clearer what WAS_FINAL_BACKSPACE does. + * src/text.c (add_undo, do_deletion): Move the check for a Delete at + the end-of-file to a less frequently travelled path. GNU nano 2.4.2 - 2015.07.05 2015-06-28 Benno Schulenberg diff --git a/src/text.c b/src/text.c index 4dae07a2..98692e39 100644 --- a/src/text.c +++ b/src/text.c @@ -120,6 +120,11 @@ void do_deletion(undo_type action) assert(openfile->current_x == strlen(openfile->current->data)); + /* When nonewlines isn't set, don't delete the final, magic newline. */ + if (!ISSET(NO_NEWLINES) && action == DEL && foo == openfile->filebot && + openfile->current_x != 0) + return; + #ifndef NANO_TINY add_undo(action); #endif @@ -876,11 +881,6 @@ void add_undo(undo_type action) ((action == ADD && u->type == ADD && u->mark_begin_x == fs->current_x) || (action == CUT && u->type == CUT && !u->mark_set && keeping_cutbuffer()))) return; - /* When trying to delete the final newline, don't add an undo for it. */ - if (action == DEL && openfile->current->next == openfile->filebot && - openfile->current->data[openfile->current_x] == '\0' && - openfile->current_x != 0 && !ISSET(NO_NEWLINES)) - return; /* Blow away the old undo stack if we are starting from the middle. */ while (fs->undotop != NULL && fs->undotop != fs->current_undo) {