Skip to content

Commit 60fd0c6

Browse files
committed
Add optional callback to GlobalCodeCheck
fixes #708
1 parent bce15cc commit 60fd0c6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

autoload/OmniSharp/actions/diagnostics.vim

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set cpoptions&vim
44
" Accepts a Funcref callback argument, to be called after the response is
55
" returned (synchronously or asynchronously) with the results
66
function! OmniSharp#actions#diagnostics#Check(...) abort
7-
let opts = a:0 && a:1 isnot 0 ? { 'Callback': a:1 } : {}
87
if bufname('%') ==# '' || OmniSharp#FugitiveCheck() | return [] | endif
8+
let opts = a:0 && a:1 isnot 0 ? { 'Callback': a:1 } : {}
99
if pumvisible() || !OmniSharp#IsServerRunning()
1010
let b:codecheck = get(b:, 'codecheck', [])
1111
if has_key(opts, 'Callback')
@@ -23,11 +23,18 @@ function! OmniSharp#actions#diagnostics#Check(...) abort
2323
endif
2424
endfunction
2525

26+
" Find all solution/project diagnostics and populate the quickfix list.
27+
" Optional argument:
28+
" Callback: When a callback is passed in, the diagnostics will be sent to
29+
" the callback *instead of* to the quickfix list.
2630
function! OmniSharp#actions#diagnostics#CheckGlobal(...) abort
2731
if bufname('%') ==# '' || OmniSharp#FugitiveCheck() | return [] | endif
28-
" Place the results in the quickfix window, if possible
29-
if g:OmniSharp_server_stdio
32+
if a:0 && a:1 isnot 0
33+
let Callback = a:1
34+
else
3035
let Callback = function('s:CBGlobalCodeCheck')
36+
endif
37+
if g:OmniSharp_server_stdio
3138
let opts = {
3239
\ 'ResponseHandler': function('s:StdioCheckRH', [Callback])
3340
\}
@@ -36,7 +43,7 @@ function! OmniSharp#actions#diagnostics#CheckGlobal(...) abort
3643
else
3744
let quickfixes = OmniSharp#py#Eval('globalCodeCheck()')
3845
if OmniSharp#py#CheckForError() | return | endif
39-
call s:CBGlobalCodeCheck(quickfixes)
46+
call Callback(quickfixes)
4047
endif
4148
endfunction
4249

0 commit comments

Comments
 (0)