diff options
author | w0rp <w0rp@users.noreply.github.com> | 2018-05-26 21:34:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-26 21:34:29 +0100 |
commit | 29a9c9a2553911200b5f80d4159e8814e34eb8ab (patch) | |
tree | 7fd35b260331749b901ecf27d8a85b21d3b0ac9d | |
parent | 6fce8ddc5ab5228afacc4c77ade1912fd3a7fe93 (diff) | |
parent | 199fcd48ac5333c6fab1ac92b802d4f23d17e491 (diff) | |
download | ale-29a9c9a2553911200b5f80d4159e8814e34eb8ab.zip |
Merge pull request #1564 from aliou/ad-alefix-fixer-cmdline-completion
Use the command line to filter ALEFix's command line completion.
-rw-r--r-- | autoload/ale/fix/registry.vim | 2 | ||||
-rw-r--r-- | test/fix/test_ale_fix_completion_filter.vader | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 7b5fdb8e..17532b3b 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -332,7 +332,7 @@ endfunction " Function that returns autocomplete candidates for ALEFix command function! ale#fix#registry#CompleteFixers(ArgLead, CmdLine, CursorPos) abort - return ale#fix#registry#GetApplicableFixers(&filetype) + return filter(ale#fix#registry#GetApplicableFixers(&filetype), 'v:val =~? a:ArgLead') endfunction " Suggest functions to use from the registry. diff --git a/test/fix/test_ale_fix_completion_filter.vader b/test/fix/test_ale_fix_completion_filter.vader new file mode 100644 index 00000000..536b7138 --- /dev/null +++ b/test/fix/test_ale_fix_completion_filter.vader @@ -0,0 +1,14 @@ +Before: + call ale#fix#registry#Clear() + call ale#test#SetFilename('test.js') + call ale#fix#registry#Add('prettier', '', ['javascript'], 'prettier') + call ale#fix#registry#Add('eslint', '', ['javascript'], 'eslint') + setfiletype javascript + +Execute(completeFixers returns all of the applicable fixers without an arglead): + AssertEqual ['eslint', 'prettier'], + \ ale#fix#registry#CompleteFixers('', 'ALEFix ', 7) + +Execute(completeFixers returns all of the applicable fixers without an arglead): + AssertEqual ['prettier'], + \ ale#fix#registry#CompleteFixers('pre', 'ALEFix ', 10) |