diff options
author | jiz4oh <41264693+jiz4oh@users.noreply.github.com> | 2023-08-20 17:43:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-20 10:43:31 +0100 |
commit | 115ad17ace047cab20ccc67f79c943aaf3f0f291 (patch) | |
tree | 73b5ca17e75995e2d150d614148eab04848def32 | |
parent | d1bac104a175dd57b134c0353e614b2c40aab269 (diff) | |
download | ale-115ad17ace047cab20ccc67f79c943aaf3f0f291.zip |
Support format xml file which haven't yet persisted at the disk (#4585)
Support format xml file which haven't yet persisted at the disk
-rw-r--r-- | autoload/ale/fixers/xmllint.vim | 11 | ||||
-rw-r--r-- | test/fixers/test_xmllint_fixer_callback.vader | 10 |
2 files changed, 19 insertions, 2 deletions
diff --git a/autoload/ale/fixers/xmllint.vim b/autoload/ale/fixers/xmllint.vim index b14ffd36..9e478feb 100644 --- a/autoload/ale/fixers/xmllint.vim +++ b/autoload/ale/fixers/xmllint.vim @@ -1,4 +1,4 @@ -" Author: Cyril Roelandt <tipecaml@gmail.com> +" Author: Cyril Roelandt <tipecaml@gmail.com>, jiz4oh <me@jiz4oh.com> " Description: Integration of xmllint with ALE. call ale#Set('xml_xmllint_executable', 'xmllint') @@ -7,7 +7,14 @@ 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 = ale#Escape(bufname(a:buffer)) + 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:indent = ale#Var(a:buffer, 'xml_xmllint_indentsize') diff --git a/test/fixers/test_xmllint_fixer_callback.vader b/test/fixers/test_xmllint_fixer_callback.vader index 54fe05bd..103b0f7b 100644 --- a/test/fixers/test_xmllint_fixer_callback.vader +++ b/test/fixers/test_xmllint_fixer_callback.vader @@ -12,6 +12,16 @@ Before: After: Restore +Execute(The xmllint callback should return the correct default command with unpersisted buffer): + new + + AssertEqual + \ { + \ 'command': ale#Escape('/path/to/xmllint') + \ . ' --format %t' + \ }, + \ ale#fixers#xmllint#Fix(bufnr('')) + Execute(The xmllint callback should return the correct default command): AssertEqual \ { |