diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix.vim | 9 | ||||
-rw-r--r-- | autoload/ale/util.vim | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim index 1ae1a4a1..03652ecf 100644 --- a/autoload/ale/fix.vim +++ b/autoload/ale/fix.vim @@ -30,7 +30,14 @@ function! ale#fix#ApplyQueuedFixes() abort call winrestview(l:save) endif - call setline(1, l:data.output) + " If the file is in DOS mode, we have to remove carriage returns from + " the ends of lines before calling setline(), or we will see them + " twice. + let l:lines_to_set = getbufvar(l:buffer, '&fileformat') is# 'dos' + \ ? map(copy(l:data.output), 'substitute(v:val, ''\r\+$'', '''', '''')') + \ : l:data.output + + call setline(1, l:lines_to_set) if l:data.should_save if empty(&buftype) diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim index 58a2065e..e0491653 100644 --- a/autoload/ale/util.vim +++ b/autoload/ale/util.vim @@ -405,7 +405,7 @@ endfunction " the buffer. function! ale#util#Writefile(buffer, lines, filename) abort let l:corrected_lines = getbufvar(a:buffer, '&fileformat') is# 'dos' - \ ? map(copy(a:lines), 'v:val . "\r"') + \ ? map(copy(a:lines), 'substitute(v:val, ''\r*$'', ''\r'', '''')') \ : a:lines call writefile(l:corrected_lines, a:filename) " no-custom-checks |