From 2f1a84f0d639773ae363c45d6723a141fe83adbf Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 15 Jun 2022 10:43:56 -0400 Subject: [PATCH] Support callback_args in request functions --- autoload/rhubarb.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autoload/rhubarb.vim b/autoload/rhubarb.vim index 40a7383..31ae42e 100644 --- a/autoload/rhubarb.vim +++ b/autoload/rhubarb.vim @@ -197,7 +197,8 @@ function! rhubarb#Request(path, ...) abort if exists('*FugitiveExecute') && v:version >= 800 try if has_key(options, 'callback') - return FugitiveExecute({'argv': args}, { r -> r.exit_status || r.stdout ==# [''] ? '' : options.callback(json_decode(join(r.stdout, ' '))) }) + return FugitiveExecute({'argv': args}, + \ { r -> r.exit_status || r.stdout ==# [''] ? '' : call(options.callback, [json_decode(join(r.stdout, ' '))] + get(options, 'callback_args', [])) }) endif let raw = join(FugitiveExecute({'argv': args}).stdout, ' ') return empty(raw) ? raw : json_decode(raw) @@ -207,7 +208,7 @@ function! rhubarb#Request(path, ...) abort let raw = system(join(map(copy(args), 's:shellesc(v:val)'), ' ')) if has_key(options, 'callback') if !v:shell_error && !empty(raw) - call options.callback(rhubarb#JsonDecode(raw)) + call call(options.callback, [rhubarb#JsonDecode(raw)] + get(options, 'callback_args', [])) endif return {} endif