From 1a8b296adfbbd253af5b62f081d4622ceb63378d Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Sat, 30 Jun 2001 18:41:08 +0000
Subject: [PATCH] write_file()  - Increment lineswritten when the very last
 line isn't null. Fixes off by one count when writing selection to file.

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

diff --git a/BUGS b/BUGS
index 2533e62a..9db3c859 100644
--- a/BUGS
+++ b/BUGS
@@ -121,7 +121,4 @@
 
 ** Open BUGS **
 
-Informal note - when using marked write to file, the number of lines
-written is off by one.  Delete this message when fixed.
-
 $Id$
diff --git a/ChangeLog b/ChangeLog
index 9f8ab3c1..124bceeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -93,6 +93,8 @@ Cvs code -
   write_file()
 	- New arg, nonamechange, means whether or not to update the
 	  current filename after writing the file out.
+	- Increment lineswritten when the very last line isn't null.
+	  Fixes off by one count when writing selection to file.
 - global.c:
 	- Updated some of the lists for the "Goto Directory" code (Rocco)
 - move.c:
diff --git a/files.c b/files.c
index f37d7a79..62dd5f72 100644
--- a/files.c
+++ b/files.c
@@ -448,6 +448,7 @@ int write_file(char *name, int tmp, int append, int nonamechange)
 	    return -1;
 	} else if (size > 0) {
 	    size = write(fd, "\n", 1);
+	    lineswritten++;
 	    if (size == -1) {
 		statusbar(_("Could not open file for writing: %s"),
 			  strerror(errno));
-- 
GitLab