From 12bb0e9634fe42e20c6fd55cb02bcc71682557ea Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Thu, 19 Sep 2019 12:20:42 +0100 Subject: [PATCH] Do not write EOL after last line when no EOL present See #650. --- autoload/gitgutter/diff.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/gitgutter/diff.vim b/autoload/gitgutter/diff.vim index 99861cc..12befde 100644 --- a/autoload/gitgutter/diff.vim +++ b/autoload/gitgutter/diff.vim @@ -381,6 +381,10 @@ function! s:write_buffer(bufnr, file) return endif + if getbufvar(a:bufnr, '&endofline') + call add(bufcontents, '') + endif + if getbufvar(a:bufnr, '&fileformat') ==# 'dos' call map(bufcontents, 'v:val."\r"') endif @@ -394,7 +398,7 @@ function! s:write_buffer(bufnr, file) let bufcontents[0]=''.bufcontents[0] endif - call writefile(bufcontents, a:file) + call writefile(bufcontents, a:file, 'b') endfunction