Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmllint fixer must read from stdin - not buffer filename #4884

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions autoload/ale/fixers/xmllint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@ call ale#Set('xml_xmllint_indentsize', 2)

function! ale#fixers#xmllint#Fix(buffer) abort
let l:executable = ale#Escape(ale#Var(a:buffer, 'xml_xmllint_executable'))
let l:filename = bufname(a:buffer)

if empty(l:filename)
let l:filename = '%t'
else
let l:filename = ale#Escape(l:filename)
endif

let l:command = l:executable . ' --format ' . l:filename
let l:command = l:executable . ' --format'

let l:indent = ale#Var(a:buffer, 'xml_xmllint_indentsize')

Expand All @@ -31,6 +24,6 @@ function! ale#fixers#xmllint#Fix(buffer) abort
endif

return {
\ 'command': l:command
\ 'command': l:command . ' -'
\}
endfunction
18 changes: 9 additions & 9 deletions test/fixers/test_xmllint_fixer_callback.vader
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,39 @@ Execute(The xmllint callback should return the correct default command with unpe
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/xmllint')
\ . ' --format %t'
\ . ' --format -'
\ },
\ ale#fixers#xmllint#Fix(bufnr(''))

Execute(The xmllint callback should return the correct default command):
call ale#test#SetFilename('../test-files/xml/dummy.xml')

AssertEqual
\ {
\ 'command': ale#Escape('/path/to/xmllint')
\ . ' --format '
\ . ale#Escape(bufname(bufnr('')))
\ . ' --format -'
\ },
\ ale#fixers#xmllint#Fix(bufnr(''))

Execute(The xmllint callback should include the XMLLINT_INDENT variable):
call ale#test#SetFilename('../test-files/xml/dummy.xml')
let g:ale_xml_xmllint_indentsize = 2

AssertEqual
\ {
\ 'command': ale#Env('XMLLINT_INDENT', ' ')
\ . ale#Escape('/path/to/xmllint')
\ . ' --format '
\ . ale#Escape(bufname(bufnr('')))
\ . ' --format -'
\ },
\ ale#fixers#xmllint#Fix(bufnr(''))

Execute(The xmllint callback should include additional options):
let g:ale_xml_xmllint_options = '--nonet'
call ale#test#SetFilename('../test-files/xml/dummy.xml')
let g:ale_xml_xmllint_options = '--nonet --custom-opt 2'

AssertEqual
\ {
\ 'command': ale#Escape('/path/to/xmllint')
\ . ' --format '
\ . ale#Escape(bufname(bufnr('')))
\ . ' --nonet'
\ . ' --format --nonet --custom-opt 2 -'
\ },
\ ale#fixers#xmllint#Fix(bufnr(''))
4 changes: 4 additions & 0 deletions test/test-files/xml/dummy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<xml>
<test id="12"/>
</xml>
Loading