Skip to content

Commit 01b7c79

Browse files
amosonnnickspoons
authored andcommitted
Refactor callbacks on usages.vim
1 parent 0fead3a commit 01b7c79

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

autoload/OmniSharp/actions/usages.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ set cpoptions&vim
77
" the callback *instead of* to the configured selector
88
" (g:OmniSharp_selector_findusages) or quickfix list.
99
function! OmniSharp#actions#usages#Find(...) abort
10-
let opts = a:0 && a:1 isnot 0 ? { 'Callback': a:1 } : {}
11-
let target = expand('<cword>')
10+
if a:0 && a:1 isnot 0
11+
let Callback = a:1
12+
else
13+
let target = expand('<cword>')
14+
let Callback = function('s:CBFindUsages', [target])
15+
endif
16+
1217
if g:OmniSharp_server_stdio
13-
let Callback = function('s:CBFindUsages', [target, opts])
1418
call s:StdioFind(Callback)
1519
else
1620
let locs = OmniSharp#py#Eval('findUsages()')
1721
if OmniSharp#py#CheckForError() | return | endif
18-
return s:CBFindUsages(target, opts, locs)
22+
return Callback(locs)
1923
endif
2024
endfunction
2125

@@ -39,12 +43,10 @@ function! s:StdioFindRH(Callback, response) abort
3943
endif
4044
endfunction
4145

42-
function! s:CBFindUsages(target, opts, locations) abort
46+
function! s:CBFindUsages(target, locations) abort
4347
let numUsages = len(a:locations)
4448
if numUsages == 0
4549
echo 'No usages found'
46-
elseif has_key(a:opts, 'Callback')
47-
call a:opts.Callback(a:locations)
4850
elseif get(g:, 'OmniSharp_selector_findusages', '') ==? 'fzf'
4951
call fzf#OmniSharp#FindUsages(a:locations, a:target)
5052
elseif get(g:, 'OmniSharp_selector_findusages', '') ==? 'clap'

0 commit comments

Comments
 (0)