From 277313b58d367b0895ac078a4c9a1b969a43e20c Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 16 Aug 2018 14:19:12 +0100 Subject: [PATCH] Fix #1816 - Fix a type error in the initialize message handler --- autoload/ale/lsp.vim | 3 ++- test/lsp/test_other_initialize_message_handling.vader | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim index 5d900138..42872dd2 100644 --- a/autoload/ale/lsp.vim +++ b/autoload/ale/lsp.vim @@ -256,7 +256,8 @@ function! ale#lsp#HandleOtherInitializeResponses(conn, response) abort endif if get(a:response, 'method', '') is# '' - if has_key(get(a:response, 'result', {}), 'capabilities') + if type(get(a:response, 'result')) is v:t_dict + \&& has_key(a:response.result, 'capabilities') call s:UpdateCapabilities(a:conn, a:response.result.capabilities) for [l:dir, l:project] in l:uninitialized_projects diff --git a/test/lsp/test_other_initialize_message_handling.vader b/test/lsp/test_other_initialize_message_handling.vader index 45457979..f5e0f1da 100644 --- a/test/lsp/test_other_initialize_message_handling.vader +++ b/test/lsp/test_other_initialize_message_handling.vader @@ -181,3 +181,10 @@ Execute(Disabled capabilities should be recognised correctly): \ }, \ }, \ b:conn + +Execute(Results that are not dictionaries should be handled correctly): + call ale#lsp#HandleOtherInitializeResponses(b:conn, { + \ 'jsonrpc': '2.0', + \ 'id': 1, + \ 'result': v:null, + \})