summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-03-29 13:42:24 +0000
committerw0rp <devw0rp@gmail.com>2019-03-29 13:42:24 +0000
commita92627e1e1bbd3dfc21ab1a16547c94e792da2a7 (patch)
tree464a0278274398b04a21e0789da11e2edde96716
parent32c8bd1fa4629d52df27103fcf18d59c5d16b343 (diff)
downloadale-a92627e1e1bbd3dfc21ab1a16547c94e792da2a7.zip
Fix #2402 - Handle null LSP references responses
-rw-r--r--autoload/ale/references.vim16
-rw-r--r--test/test_find_references.vader17
2 files changed, 18 insertions, 15 deletions
diff --git a/autoload/ale/references.vim b/autoload/ale/references.vim
index 0e88afe2..b9725e1e 100644
--- a/autoload/ale/references.vim
+++ b/autoload/ale/references.vim
@@ -49,13 +49,15 @@ function! ale#references#HandleLSPResponse(conn_id, response) abort
let l:result = get(a:response, 'result', [])
let l:item_list = []
- for l:response_item in l:result
- call add(l:item_list, {
- \ 'filename': ale#path#FromURI(l:response_item.uri),
- \ 'line': l:response_item.range.start.line + 1,
- \ 'column': l:response_item.range.start.character + 1,
- \})
- endfor
+ if type(l:result) is v:t_list
+ for l:response_item in l:result
+ call add(l:item_list, {
+ \ 'filename': ale#path#FromURI(l:response_item.uri),
+ \ 'line': l:response_item.range.start.line + 1,
+ \ 'column': l:response_item.range.start.character + 1,
+ \})
+ endfor
+ endif
if empty(l:item_list)
call ale#util#Execute('echom ''No references found.''')
diff --git a/test/test_find_references.vader b/test/test_find_references.vader
index eb06e3bc..1a147849 100644
--- a/test/test_find_references.vader
+++ b/test/test_find_references.vader
@@ -253,14 +253,15 @@ Execute(LSP reference responses should be handled):
Execute(Preview windows should not be opened for empty LSP reference responses):
call ale#references#SetMap({3: {}})
- call ale#references#HandleLSPResponse(
- \ 1,
- \ {
- \ 'id': 3,
- \ 'result': [
- \ ],
- \ }
- \)
+ call ale#references#HandleLSPResponse(1, {'id': 3, 'result': []})
+
+ Assert !g:preview_called
+ AssertEqual {}, ale#references#GetMap()
+ AssertEqual ['echom ''No references found.'''], g:expr_list
+
+Execute(LSP reference responses with a null result should be handled):
+ call ale#references#SetMap({3: {}})
+ call ale#references#HandleLSPResponse(1, {'id': 3, 'result': v:null})
Assert !g:preview_called
AssertEqual {}, ale#references#GetMap()