Skip to content

Commit 2ee68e7

Browse files
amosonnnickspoons
authored andcommitted
When callback present, don't navigate.
Callback receives full location, not just count. Everywhere except for GotoDefinition.
1 parent a78ec04 commit 2ee68e7

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

autoload/OmniSharp/actions/implementations.vim

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@ let s:save_cpo = &cpoptions
22
set cpoptions&vim
33

44
" Accepts a Funcref callback argument, to be called after the response is
5-
" returned (synchronously or asynchronously) with the number of implementations
5+
" returned (synchronously or asynchronously) with the list of found locations.
6+
" This is done instead of navigating to them or showing a quick-fix.
67
function! OmniSharp#actions#implementations#Find(...) abort
7-
let opts = a:0 && a:1 isnot 0 ? { 'Callback': a:1 } : {}
8-
let target = expand('<cword>')
8+
if a:0 && a:1 isnot 0
9+
let Callback = a:1
10+
else
11+
let target = expand('<cword>')
12+
let Callback = function('s:CBFindImplementations', [target])
13+
endif
14+
915
if g:OmniSharp_server_stdio
10-
let Callback = function('s:CBFindImplementations', [target, opts])
1116
call s:StdioFind(Callback)
1217
else
1318
let locs = OmniSharp#py#Eval('findImplementations()')
1419
if OmniSharp#py#CheckForError() | return | endif
15-
return s:CBFindImplementations(target, opts, locs)
20+
return Callback(locs)
1621
endif
1722
endfunction
1823

@@ -44,7 +49,7 @@ function! s:StdioFindRH(Callback, response) abort
4449
endif
4550
endfunction
4651

47-
function! s:CBFindImplementations(target, opts, locations) abort
52+
function! s:CBFindImplementations(target, locations) abort
4853
let numImplementations = len(a:locations)
4954
if numImplementations == 0
5055
echo 'No implementations found'
@@ -55,9 +60,6 @@ function! s:CBFindImplementations(target, opts, locations) abort
5560
call OmniSharp#locations#SetQuickfix(locations,
5661
\ 'Implementations: ' . a:target)
5762
endif
58-
if has_key(a:opts, 'Callback')
59-
call a:opts.Callback(numImplementations)
60-
endif
6163
return numImplementations
6264
endfunction
6365

autoload/OmniSharp/actions/members.vim

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@ let s:save_cpo = &cpoptions
22
set cpoptions&vim
33

44
" Accepts a Funcref callback argument, to be called after the response is
5-
" returned (synchronously or asynchronously) with the number of members
5+
" returned (synchronously or asynchronously) with the list of found locations
6+
" of members.
7+
" This is done instead of showing a quick-fix.
68
function! OmniSharp#actions#members#Find(...) abort
7-
let opts = a:0 && a:1 isnot 0 ? { 'Callback': a:1 } : {}
9+
if a:0 && a:1 isnot 0
10+
let Callback = a:1
11+
else
12+
let Callback = function('s:CBFindMembers')
13+
endif
14+
815
if g:OmniSharp_server_stdio
9-
call s:StdioFind(function('s:CBFindMembers', [opts]))
16+
call s:StdioFind(Callback)
1017
else
1118
let locs = OmniSharp#py#Eval('findMembers()')
1219
if OmniSharp#py#CheckForError() | return | endif
13-
return s:CBFindMembers(opts, locs)
20+
return Callback(locs)
1421
endif
1522
endfunction
1623

@@ -83,14 +90,11 @@ function! ReduceToOneCharacter(textBeforeDisplayName) abort
8390
return s:SingleCharacterSymbolByAccessModifier[accessModifier] . a:textBeforeDisplayName[accessModifierLen:]
8491
endfunction
8592

86-
function! s:CBFindMembers(opts, locations) abort
93+
function! s:CBFindMembers(locations) abort
8794
let numMembers = len(a:locations)
8895
if numMembers > 0
8996
call OmniSharp#locations#SetQuickfixWithVerticalAlign(a:locations, 'Members')
9097
endif
91-
if has_key(a:opts, 'Callback')
92-
call a:opts.Callback(numMembers)
93-
endif
9498
return numMembers
9599
endfunction
96100

autoload/OmniSharp/actions/usings.vim

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ let s:save_cpo = &cpoptions
22
set cpoptions&vim
33

44
" Accepts a Funcref callback argument, to be called after the response is
5-
" returned (synchronously or asynchronously) with the number of ambiguous usings
5+
" returned (synchronously or asynchronously) with the list of locations of
6+
" ambiguous usings.
7+
" This is done instead of showing a quick-fix.
68
function! OmniSharp#actions#usings#Fix(...) abort
7-
let opts = a:0 && a:1 isnot 0 ? { 'Callback': a:1 } : {}
9+
if a:0 && a:1 isnot 0
10+
let Callback = a:1
11+
else
12+
let Callback = function('s:CBFixUsings')
13+
endif
14+
815
if g:OmniSharp_server_stdio
9-
let Callback = function('s:CBFixUsings', [opts])
1016
call s:StdioFix(Callback)
1117
else
1218
let locs = OmniSharp#py#Eval('fixUsings()')
1319
if OmniSharp#py#CheckForError() | return | endif
14-
return s:CBFixUsings(opts, locs)
20+
return Callback(locs)
1521
endif
1622
endfunction
1723

@@ -43,15 +49,12 @@ function! s:StdioFixRH(Callback, response) abort
4349
endif
4450
endfunction
4551

46-
function! s:CBFixUsings(opts, locations) abort
52+
function! s:CBFixUsings(locations) abort
4753
let numAmbiguous = len(a:locations)
4854
if numAmbiguous > 0
4955
let locations = OmniSharp#locations#Modify(a:locations)
5056
call OmniSharp#locations#SetQuickfix(locations, 'Ambiguous usings')
5157
endif
52-
if has_key(a:opts, 'Callback')
53-
call a:opts.Callback(numAmbiguous)
54-
endif
5558
return numAmbiguous
5659
endfunction
5760

0 commit comments

Comments
 (0)