Fix #2295 - Respond to initialize with an initialized message

This commit is contained in:
w0rp
2019-02-15 08:54:53 +00:00
parent 89039187da
commit 0d10653a7c
10 changed files with 132 additions and 57 deletions

View File

@@ -38,10 +38,10 @@ Before:
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
let l:details = {
\ 'command': 'foobar',
\ 'buffer': a:buffer,
\ 'connection_id': g:conn_id,
\ 'project_root': '/foo/bar',
\ 'language_id': 'foobar',
\}
call a:Callback(a:linter, l:details)

View File

@@ -1,5 +1,9 @@
Before:
runtime autoload/ale/lsp.vim
let g:message_list = []
let b:conn = {
\ 'id': 1,
\ 'is_tsserver': 0,
\ 'data': '',
\ 'root': '/foo/bar',
@@ -21,8 +25,17 @@ Before:
\ },
\}
function! ale#lsp#Send(conn_id, message) abort
call add(g:message_list, a:message)
return 42
endfunction
After:
unlet! b:conn
unlet! g:message_list
runtime autoload/ale/lsp.vim
Execute(Messages with no method and capabilities should initialize projects):
call ale#lsp#HandleInitResponse(b:conn, {
@@ -30,15 +43,18 @@ Execute(Messages with no method and capabilities should initialize projects):
\})
AssertEqual 1, b:conn.initialized
AssertEqual [[1, 'initialized']], g:message_list
Execute(Other messages should not initialize projects):
call ale#lsp#HandleInitResponse(b:conn, {'method': 'lolwat'})
AssertEqual 0, b:conn.initialized
AssertEqual [], g:message_list
call ale#lsp#HandleInitResponse(b:conn, {'result': {'x': {}}})
AssertEqual 0, b:conn.initialized
AssertEqual [], g:message_list
Execute(Capabilities should bet set up correctly):
call ale#lsp#HandleInitResponse(b:conn, {
@@ -86,6 +102,7 @@ Execute(Capabilities should bet set up correctly):
\ 'symbol_search': 1,
\ },
\ b:conn.capabilities
AssertEqual [[1, 'initialized']], g:message_list
Execute(Disabled capabilities should be recognised correctly):
call ale#lsp#HandleInitResponse(b:conn, {
@@ -128,6 +145,7 @@ Execute(Disabled capabilities should be recognised correctly):
\ 'symbol_search': 0,
\ },
\ b:conn.capabilities
AssertEqual [[1, 'initialized']], g:message_list
Execute(Results that are not dictionaries should be handled correctly):
call ale#lsp#HandleInitResponse(b:conn, {
@@ -135,3 +153,4 @@ Execute(Results that are not dictionaries should be handled correctly):
\ 'id': 1,
\ 'result': v:null,
\})
AssertEqual [], g:message_list

View File

@@ -3,6 +3,10 @@ Before:
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
" Stub out this function, so we test updating configs.
function! ale#lsp#Send(conn_id, message) abort
endfunction
After:
Restore