]> git.wh0rd.org Git - nano.git/commitdiff
Moving the check for a Delete at the end-of-file to a less frequently
authorBenno Schulenberg <bensberg@justemail.net>
Mon, 6 Jul 2015 18:48:15 +0000 (18:48 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Mon, 6 Jul 2015 18:48:15 +0000 (18:48 +0000)
travelled code path.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5284 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/text.c

index 5c73b25b1d0e4266bd55932b82c2ef25781865a8..c4c505fef1c027c9f1f581006c38eaa85d651668 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,11 @@
-2015-06-28  Benno Schulenberg  <bensberg@justemail.net>
+2015-07-06  Benno Schulenberg  <bensberg@justemail.net>
        * 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  <bensberg@justemail.net>
index 4dae07a28d9904ab67cfae79540e205feff6f6b7..98692e39c1635565640b0b85d570c7d5d4a16cf4 100644 (file)
@@ -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) {