Revert to non-binary writefile() for writing buffer.

The previous commit switched use of writefile() to binary mode so that
we could prevent a newline being added to a completely empty buffer.
Evidently, however, binary mode has side effects (see #567) so this
commit returns to non-binary mode - with a simpler fix for completely
empty files.

Unfortunately this implementation does not work for noeol files - see
the failing test - because writefile() does not take account of
'nofixeol' (unlike :write).  This is suboptimal but acceptable because
noeol files are not be encountered often.

See #567.
This commit is contained in:
Andy Stewart
2018-12-15 14:55:14 +00:00
parent 5c636b128e
commit 1d422b9f98
2 changed files with 5 additions and 9 deletions

View File

@@ -669,7 +669,7 @@ function Test_empty_file()
" 1 line file without newline
" Vim will force a newline unless we tell it not to.
call system('echo -n "a" > oneline.txt && git add oneline.txt')
call system('echo -n a > oneline.txt && git add oneline.txt')
set noeol nofixeol
edit! oneline.txt