mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-09 04:52:29 +08:00
Fix #823 - Write Windows files with CRLF
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user