mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 05:24:46 +08:00
Refactor the "s:LoadArgCount()" function (#3025)
* Refactor the "s:LoadArgCount()" function
Previously, this function would always set "v:errmsg" on the first
call with a given function. This is because autoloaded functions
are not defined on the first call.
A number of improvements have been made:
- a useless local function ("l:Function") is removed
- the "execute()" builtin captures the output, instead of ":redir"
- a ":try" block handles the case where a function is not defined
- a useless ":if" is removed since ":redir" always defines the var
- confusing quoting is re-written (remove double "'" chars)
Fixes: #3021
This commit is contained in:
@@ -336,15 +336,11 @@ function! ale#util#GetMatches(lines, patterns) abort
|
||||
endfunction
|
||||
|
||||
function! s:LoadArgCount(function) abort
|
||||
let l:Function = a:function
|
||||
|
||||
redir => l:output
|
||||
silent! function Function
|
||||
redir END
|
||||
|
||||
if !exists('l:output')
|
||||
try
|
||||
let l:output = execute('function a:function')
|
||||
catch /E123/
|
||||
return 0
|
||||
endif
|
||||
endtry
|
||||
|
||||
let l:match = matchstr(split(l:output, "\n")[0], '\v\([^)]+\)')[1:-2]
|
||||
let l:arg_list = filter(split(l:match, ', '), 'v:val isnot# ''...''')
|
||||
|
||||
Reference in New Issue
Block a user