diff options
author | w0rp <devw0rp@gmail.com> | 2018-06-01 14:15:32 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-06-01 14:15:32 +0100 |
commit | 6a7e00d9aca6aad374afcc8a64e322693bde55d8 (patch) | |
tree | e3f0d5ce8d09bf623e225ce45d982c3cd7160933 | |
parent | 10e1545630943aa98320b62f97f79a6f85340e51 (diff) | |
download | ale-6a7e00d9aca6aad374afcc8a64e322693bde55d8.zip |
Handle definition responses without files
-rw-r--r-- | autoload/ale/definition.vim | 2 | ||||
-rw-r--r-- | test/test_go_to_definition.vader | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/autoload/ale/definition.vim b/autoload/ale/definition.vim index a3bfcd17..a17eb2e7 100644 --- a/autoload/ale/definition.vim +++ b/autoload/ale/definition.vim @@ -22,7 +22,7 @@ function! ale#definition#HandleTSServerResponse(conn_id, response) abort \&& has_key(s:go_to_definition_map, a:response.request_seq) let l:options = remove(s:go_to_definition_map, a:response.request_seq) - if get(a:response, 'success', v:false) is v:true + if get(a:response, 'success', v:false) is v:true && !empty(a:response.body) let l:filename = a:response.body[0].file let l:line = a:response.body[0].start.line let l:column = a:response.body[0].start.offset diff --git a/test/test_go_to_definition.vader b/test/test_go_to_definition.vader index 5bd75675..6af97099 100644 --- a/test/test_go_to_definition.vader +++ b/test/test_go_to_definition.vader @@ -56,6 +56,19 @@ Execute(Failed definition responses should be handled correctly): \) AssertEqual {}, ale#definition#GetMap() +Execute(Failed definition responses with no files should be handled correctly): + call ale#definition#SetMap({3: {'open_in_tab': 0}}) + call ale#definition#HandleTSServerResponse( + \ 1, + \ { + \ 'command': 'definition', + \ 'request_seq': 3, + \ 'success': v:true, + \ 'body': [], + \ } + \) + AssertEqual {}, ale#definition#GetMap() + Given typescript(Some typescript file): foo somelongerline |