From 45bf18856baac9dec04bc4512ca16293902af122 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 22 Jul 2018 09:08:35 +0200 Subject: [PATCH] text: create an undo item for ENTER before changing the file size The undo item should record the file size before anything is added by the ENTER action -- in this case: auto-indentation whitespace. This fixes https://savannah.gnu.org/bugs/?54344. Reported-by: Liu Hao --- src/text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/text.c b/src/text.c index f9bfa7e2..0f97514b 100644 --- a/src/text.c +++ b/src/text.c @@ -1022,6 +1022,8 @@ void do_enter(void) filestruct *sampleline = openfile->current; bool allblanks = FALSE; + add_undo(ENTER); + if (ISSET(AUTOINDENT)) { #ifdef ENABLE_JUSTIFY /* When doing automatic long-line wrapping and the next line is @@ -1058,8 +1060,6 @@ void do_enter(void) null_at(&openfile->current->data, openfile->current_x); #ifndef NANO_TINY - add_undo(ENTER); - /* Adjust the mark if it was on the current line after the cursor. */ if (openfile->mark == openfile->current && openfile->mark_x > openfile->current_x) { -- 2.17.1