commit 8f5fa24e517161c6b4bb8343c9bddcbaf7444f11
parent 619666460ef108b42d6600f3157fa858b9226531
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 6 Jul 2015 18:48:15 +0000
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
Diffstat:
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git 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>
diff --git 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) {