summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bufwrite.c2
-rw-r--r--src/testdir/test_writefile.vim18
-rw-r--r--src/version.c2
3 files changed, 21 insertions, 1 deletions
diff --git a/src/bufwrite.c b/src/bufwrite.c
index c6d882cd5f..d7c74de35c 100644
--- a/src/bufwrite.c
+++ b/src/bufwrite.c
@@ -2031,7 +2031,7 @@ restore_backup:
if (end == 0
|| (lnum == end
&& (write_bin || !buf->b_p_fixeol)
- && (lnum == buf->b_no_eol_lnum
+ && ((write_bin && lnum == buf->b_no_eol_lnum)
|| (lnum == buf->b_ml.ml_line_count
&& !buf->b_p_eol))))
{
diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim
index c858b7521a..f42ec14bb1 100644
--- a/src/testdir/test_writefile.vim
+++ b/src/testdir/test_writefile.vim
@@ -676,4 +676,22 @@ func Test_readwrite_file_with_bom()
%bw!
endfunc
+func Test_read_write_bin()
+ " write file missing EOL
+ call writefile(['noeol'], "XNoEolSetEol", 'bS')
+ call assert_equal(0z6E6F656F6C, readfile('XNoEolSetEol', 'B'))
+
+ " when file is read 'eol' is off
+ set ff=unix nofixeol
+ e XNoEolSetEol
+ call assert_equal(0, &eol)
+
+ " writing with 'eol' set adds the newline
+ setlocal eol
+ w
+ call assert_equal(0z6E6F656F6C0A, readfile('XNoEolSetEol', 'B'))
+
+ call delete('XNoEolSetEol')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index af89c9e305..0fadf6b930 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2199,
+/**/
2198,
/**/
2197,