From: Benno Schulenberg Date: Mon, 6 Jul 2015 19:08:13 +0000 (+0000) Subject: Not removing and then re-adding the magic line when a Backspace happens X-Git-Tag: v2.5.0~177 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=fc7825d00d62511cb8aa528f285b9a09f10ee608;p=nano.git Not removing and then re-adding the magic line when a Backspace happens at the end-of-file; just adding a token undo item to be able to put the cursor back at the very tail of the file. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5285 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index c4c505fe..9e399bf3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ * 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. + * src/text.c (do_deletion): If a Backspace happens at the end-of-file, + don't remove and then re-add the magic line; just add an undo item. GNU nano 2.4.2 - 2015.07.05 2015-06-28 Benno Schulenberg diff --git a/src/text.c b/src/text.c index 98692e39..7fc19761 100644 --- a/src/text.c +++ b/src/text.c @@ -121,9 +121,14 @@ 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) + if (!ISSET(NO_NEWLINES) && foo == openfile->filebot && + openfile->current_x != 0) { +#ifndef NANO_TINY + if (action == BACK) + add_undo(BACK); +#endif return; + } #ifndef NANO_TINY add_undo(action); @@ -149,13 +154,6 @@ void do_deletion(undo_type action) /* Two lines were joined, so we need to refresh the screen. */ edit_refresh_needed = TRUE; - - /* If the NO_NEWLINES flag isn't set, and text has been added to - * the magicline as a result of deleting at the end of the line - * before filebot, add a new magicline. */ - if (!ISSET(NO_NEWLINES) && openfile->current == openfile->filebot && - openfile->current->data[0] != '\0') - new_magicline(); } else return;