From 78d644a635ab300fc039ddac97ab86451da3a554 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Fri, 5 Nov 2004 16:24:35 +0000
Subject: [PATCH] don't change the file format when we insert another file into
 the current one

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2066 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   | 3 +++
 src/files.c | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f066cff6..4cde9a7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -118,6 +118,9 @@ CVS code -
   read_file()
 	- Rename variable fileformat to format, to avoid confusion with
 	  the file_format enum type. (DLR)
+  load_buffer()
+	- Don't change the file format when we insert another file into
+	  the current one. (DLR)
   do_insertfile()
 	- Simplify by reusing variables whereever possible, and add a
 	  parameter execute to indicate whether or not to be in "Execute
diff --git a/src/files.c b/src/files.c
index 7e0c07dd..bcef6f13 100644
--- a/src/files.c
+++ b/src/files.c
@@ -466,7 +466,15 @@ void load_buffer(const char *name)
     }
 
     if (rc == 0) {
+	file_format fmt_save = fmt;
+
 	read_file(f, filename);
+
+	/* If we're not loading into a new buffer, preserve the file
+	 * format. */
+	if (!new_buffer)
+	    fmt = fmt_save;
+
 #ifndef NANO_SMALL
 	stat(filename, &originalfilestat);
 #endif
-- 
GitLab