diff options
author | w0rp <devw0rp@gmail.com> | 2017-08-05 20:17:25 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-08-05 20:17:25 +0100 |
commit | 593cafa18b627b8911da4810fe0fe25e1d18e7eb (patch) | |
tree | 0e91e94009fa9f2c33319783fa74db25705db188 /autoload | |
parent | 747d4fe80b8dfdc65260868230b8e3fded328228 (diff) | |
download | ale-593cafa18b627b8911da4810fe0fe25e1d18e7eb.zip |
Fix #823 - Write Windows files with CRLF
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/engine.vim | 3 | ||||
-rw-r--r-- | autoload/ale/fix.vim | 2 | ||||
-rw-r--r-- | autoload/ale/util.vim | 12 |
3 files changed, 15 insertions, 2 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index a5a5f524..9b90e953 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -417,7 +417,8 @@ function! s:CreateTemporaryFileForJob(buffer, temporary_file) abort " Automatically delete the directory later. call ale#engine#ManageDirectory(a:buffer, l:temporary_directory) " Write the buffer out to a file. - call writefile(getbufline(a:buffer, 1, '$'), a:temporary_file) + let l:lines = getbufline(a:buffer, 1, '$') + call ale#util#Writefile(a:buffer, l:lines, a:temporary_file) return 1 endfunction diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim index 12cbea4d..73992125 100644 --- a/autoload/ale/fix.vim +++ b/autoload/ale/fix.vim @@ -154,7 +154,7 @@ function! s:CreateTemporaryFileForJob(buffer, temporary_file, input) abort " Automatically delete the directory later. call ale#fix#ManageDirectory(a:buffer, l:temporary_directory) " Write the buffer out to a file. - call writefile(a:input, a:temporary_file) + call ale#util#Writefile(a:buffer, a:input, a:temporary_file) return 1 endfunction diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim index f3146151..312f8f0f 100644 --- a/autoload/ale/util.vim +++ b/autoload/ale/util.vim @@ -187,3 +187,15 @@ function! ale#util#FuzzyJSONDecode(data, default) abort return a:default endtry endfunction + +" Write a file, including carriage return characters for DOS files. +" +" The buffer number is required for determining the fileformat setting for +" the buffer. +function! ale#util#Writefile(buffer, lines, filename) abort + let l:corrected_lines = getbufvar(a:buffer, '&fileformat') ==# 'dos' + \ ? map(copy(a:lines), 'v:val . "\r"') + \ : a:lines + + call writefile(l:corrected_lines, a:filename) " no-custom-checks +endfunction |