From 31fe0753e37d4901f0a8140b1cf5889cbacc37e7 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 19 Dec 2017 17:57:49 +0100
Subject: [PATCH] tweaks: limit the resetting of "Modified" to writing a full
 buffer

When doing that, there is no need to save and restore the Modified
state when writing a marked region.
---
 src/files.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/files.c b/src/files.c
index cdd9f2cd..071bab21 100644
--- a/src/files.c
+++ b/src/files.c
@@ -1949,16 +1949,17 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
 #endif
 	}
 
+	if (fullbuffer) {
 #ifndef NANO_TINY
-	if (fullbuffer)
 	    /* Get or update the stat info to reflect the current state. */
 	    stat_with_alloc(realname, &openfile->current_stat);
 #endif
+	    openfile->modified = FALSE;
+	    titlebar(NULL);
+	}
 
 	statusline(HUSH, P_("Wrote %zu line", "Wrote %zu lines",
 			lineswritten), lineswritten);
-	openfile->modified = FALSE;
-	titlebar(NULL);
     }
 
     retval = TRUE;
@@ -1977,8 +1978,6 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
 	kind_of_writing_type method)
 {
     bool retval;
-    bool old_modified = openfile->modified;
-	/* Save the status, as writing the file unsets the modified flag. */
     bool added_magicline = FALSE;
 	/* Whether we added a magicline after filebot. */
     filestruct *top, *bot;
@@ -2005,9 +2004,6 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
     /* Unpartition the buffer so that it contains all the text again. */
     unpartition_filestruct(&filepart);
 
-    if (old_modified)
-	set_modified();
-
     return retval;
 }
 
-- 
GitLab