From edf230b7df4e3718d31bbf1ada7d44ebe23706d6 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 4 Jun 2016 11:35:11 +0200
Subject: [PATCH] text: store the new file size in the undo item also when
 joining lines

This fixes https://savannah.gnu.org/bugs/?48099 reported by Mike Scalora.
---
 src/text.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/text.c b/src/text.c
index d59da21a..1d62bfc8 100644
--- a/src/text.c
+++ b/src/text.c
@@ -137,6 +137,9 @@ void do_deletion(undo_type action)
 		strlen(openfile->current->data) + strlen(foo->data) + 1);
 	strcat(openfile->current->data, foo->data);
 
+	/* Adjust the file size, and remember it for a possible redo. */
+	openfile->current_undo->newsize = --(openfile->totsize);
+
 #ifndef NANO_TINY
 	if (openfile->mark_set &&
 		openfile->mark_begin == openfile->current->next) {
@@ -146,7 +149,6 @@ void do_deletion(undo_type action)
 #endif
 	unlink_node(foo);
 	renumber(openfile->current);
-	openfile->totsize--;
 
 	/* Two lines were joined, so we need to refresh the screen. */
 	refresh_needed = TRUE;
-- 
GitLab