Skip to content

Commit 6d795af

Browse files
amosonnnickspoons
authored andcommitted
Clean callback in definition
1 parent 9fa205b commit 6d795af

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

autoload/OmniSharp/actions/definition.vim

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,24 @@ set cpoptions&vim
44
" Navigate to the definition of the symbol under the cursor.
55
" Optional arguments:
66
" Callback: When a callback is passed in, it is called after the response is
7-
" returned (synchronously or asynchronously) with a boolean 'found'
8-
" result.
7+
" returned (synchronously or asynchronously) with the found
8+
" location and a flag for whether it is in a file in the project or
9+
" from the metadata. This is done instead of navigating to the found
10+
" location.
911
" editcommand: The command to use to open buffers, e.g. 'split', 'vsplit',
1012
" 'tabedit' or 'edit' (default).
1113
function! OmniSharp#actions#definition#Find(...) abort
12-
let opts = { 'editcommand': 'edit' }
1314
if a:0 && type(a:1) == type(function('tr'))
14-
let opts.Callback = a:1
15-
endif
16-
if a:0 > 1 && type(a:2) == type(function('tr'))
17-
let opts.Callback = a:2
18-
endif
15+
let Callback = a:1
16+
else
17+
let opts = { 'editcommand': 'edit' }
1918
if a:0 && type(a:1) == type('') && a:1 !=# ''
2019
let opts.editcommand = a:1
2120
endif
22-
if a:0 > 1 && type(a:2) == type('') && a:1 !=# ''
23-
let opts.editcommand = a:2
21+
let Callback = function('s:CBGotoDefinition', [opts])
2422
endif
23+
2524
if g:OmniSharp_server_stdio
26-
let Callback = function('s:CBGotoDefinition', [opts])
2725
call s:StdioFind(Callback)
2826
else
2927
let loc = OmniSharp#py#Eval('gotoDefinition()')
@@ -33,8 +31,7 @@ function! OmniSharp#actions#definition#Find(...) abort
3331
endif
3432
endfunction
3533

36-
function! OmniSharp#actions#definition#Preview(...) abort
37-
let opts = a:0 && a:1 isnot 0 ? { 'Callback': a:1 } : {}
34+
function! OmniSharp#actions#definition#Preview() abort
3835
if g:OmniSharp_server_stdio
3936
let Callback = function('s:CBPreviewDefinition')
4037
call s:StdioFind(Callback)
@@ -115,9 +112,6 @@ function! s:CBGotoDefinition(opts, location, fromMetadata) abort
115112
setlocal nomodifiable readonly
116113
endif
117114
endif
118-
if has_key(a:opts, 'Callback')
119-
call a:opts.Callback(found)
120-
endif
121115
return found
122116
endfunction
123117

0 commit comments

Comments
 (0)