Skip to content

Commit b09b00d

Browse files
committed
Use both 'Event' and 'Body' to parse events
1 parent b8d5046 commit b09b00d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

autoload/OmniSharp/project.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function! OmniSharp#project#CountTotal() abort
1414
endfunction
1515

1616
" Listen for stdio server-loaded events
17-
function! OmniSharp#project#ParseEvent(job, eventBody) abort
17+
function! OmniSharp#project#ParseEvent(job, event, eventBody) abort
1818
if g:OmniSharp_server_stdio_quickload
1919

2020
" Quick load: Mark server as loaded as soon as configuration is finished

autoload/OmniSharp/stdio.vim

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ function! OmniSharp#stdio#HandleResponse(job, message) abort
4747
endfunction
4848

4949
function! 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

153158
function! 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

Comments
 (0)