@@ -47,10 +47,15 @@ function! OmniSharp#stdio#HandleResponse(job, message) abort
4747endfunction
4848
4949function ! s: HandleServerEvent (job, res ) abort
50- if has_key (a: res , ' Body' ) && type (a: res .Body) == type ({})
50+ let body = get (a: res , ' Body' , 0 )
51+ if type (body) != type ({})
52+ let body = {}
53+ endif
54+
55+ " Handle any project loading events
56+ call OmniSharp#project#ParseEvent (a: job , get (a: res , ' Event' , ' ' ), body)
5157
52- " Handle any project loading events
53- call OmniSharp#project#ParseEvent (a: job , a: res .Body)
58+ if ! empty (body)
5459
5560 " Listen for diagnostics.
5661 " The OmniSharp-roslyn server starts sending diagnostics once projects are
@@ -60,7 +65,7 @@ function! s:HandleServerEvent(job, res) abort
6065 if get (g: , ' OmniSharp_diagnostics_listen' , 0 )
6166 \ && has_key (g: , ' OmniSharp_ale_diagnostics_requested' )
6267 if get (a: res , ' Event' , ' ' ) == # ' Diagnostic'
63- for result in get (a: res .Body , ' Results' , [])
68+ for result in get (body , ' Results' , [])
6469 let fname = OmniSharp#util#TranslatePathForClient (result.FileName)
6570 let bufinfo = getbufinfo (fname)
6671 if len (bufinfo) == 0 || ! has_key (bufinfo[0 ], ' bufnr' )
@@ -77,9 +82,9 @@ function! s:HandleServerEvent(job, res) abort
7782
7883 " Diagnostics received while running tests
7984 if get (a: res , ' Event' , ' ' ) == # ' TestMessage'
80- let lines = split (a: res .Body .Message, ' \n' )
85+ let lines = split (body .Message, ' \n' )
8186 for line in lines
82- if get (a: res .Body , ' MessageLevel' , ' ' ) == # ' error'
87+ if get (body , ' MessageLevel' , ' ' ) == # ' error'
8388 echohl WarningMsg | echomsg line | echohl None
8489 elseif g: OmniSharp_runtests_echo_output
8590 echomsg line
@@ -152,7 +157,8 @@ endfunction
152157
153158function ! s: Request (job, body, command , opts, ... ) abort
154159 let sep = a: 0 ? a: 1 : ' '
155- if type (a: job ) != type ({}) || ! has_key (a: job , ' job_id' ) || ! a: job .loaded
160+ if ! has_key (a: opts , ' AllowUnloaded' ) &&
161+ \ (! has_key (a: job , ' job_id' ) || ! a: job .loaded)
156162 if has_key (a: opts , ' ReplayOnLoad' ) && ! has_key (s: pendingRequests , a: command )
157163 " This request should be replayed when the server is fully loaded
158164 let s: pendingRequests [a: command ] = a: opts
0 commit comments