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
master
Benno Schulenberg 2015-07-06 19:08:13 +00:00
parent 8f5fa24e51
commit fc7825d00d
2 changed files with 9 additions and 9 deletions

View File

@ -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 <bensberg@justemail.net>

View File

@ -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;