summaryrefslogtreecommitdiff
path: root/test/completion
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-08-27 08:44:43 +0100
committerw0rp <devw0rp@gmail.com>2020-08-27 08:44:43 +0100
commit396fba7cca5bb6cd5774173241e3e606045e1c46 (patch)
treeb72687eee6fd139630e53660f5faa55124a84f03 /test/completion
parent3e2abe3f25493af63af91a6013447e378e09f6ec (diff)
downloadale-396fba7cca5bb6cd5774173241e3e606045e1c46.zip
Fix #3312 - Fix a false positive for auto imports
ALE was incorrectly detecting completion results from servers such as rust-analyzer as wanting to add import lines when additionalTextEdits was present, but empty. Now ALE only filters out completion results if the autoimport setting is off, and one of the additionalTextEdits starts on some line other than the current line. If any additionalTextEdits happen to be identical to the change from completion anyway, ALE will skip them.
Diffstat (limited to 'test/completion')
-rw-r--r--test/completion/test_lsp_completion_parsing.vader76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader
index 8b8b41c7..395314d7 100644
--- a/test/completion/test_lsp_completion_parsing.vader
+++ b/test/completion/test_lsp_completion_parsing.vader
@@ -537,6 +537,7 @@ Execute(Should handle completion messages with the deprecated insertText attribu
Execute(Should handle completion messages with additionalTextEdits when ale_completion_autoimport is turned on):
let g:ale_completion_autoimport = 1
+ let b:ale_completion_info = {'line': 30}
AssertEqual
\ [
@@ -591,6 +592,19 @@ Execute(Should handle completion messages with additionalTextEdits when ale_comp
\ {
\ 'range': {
\ 'start': {
+ \ 'line': 29,
+ \ 'character': 10,
+ \ },
+ \ 'end': {
+ \ 'line': 29,
+ \ 'character': 10,
+ \ },
+ \ },
+ \ 'newText': 'next_callback',
+ \ },
+ \ {
+ \ 'range': {
+ \ 'start': {
\ 'line': 10,
\ 'character': 1,
\ },
@@ -609,6 +623,7 @@ Execute(Should handle completion messages with additionalTextEdits when ale_comp
Execute(Should not handle completion messages with additionalTextEdits when ale_completion_autoimport is turned off):
let g:ale_completion_autoimport = 0
+ let b:ale_completion_info = {'line': 30}
AssertEqual
\ [],
@@ -630,6 +645,19 @@ Execute(Should not handle completion messages with additionalTextEdits when ale_
\ {
\ 'range': {
\ 'start': {
+ \ 'line': 29,
+ \ 'character': 10,
+ \ },
+ \ 'end': {
+ \ 'line': 29,
+ \ 'character': 10,
+ \ },
+ \ },
+ \ 'newText': 'next_callback',
+ \ },
+ \ {
+ \ 'range': {
+ \ 'start': {
\ 'line': 10,
\ 'character': 1,
\ },
@@ -645,3 +673,51 @@ Execute(Should not handle completion messages with additionalTextEdits when ale_
\ ],
\ },
\ })
+
+Execute(Should still handle completion messages with additionalTextEdits with ale_completion_autoimport turned off, if edits all start on the line):
+ let g:ale_completion_autoimport = 0
+ let b:ale_completion_info = {'line': 30}
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'word': 'next_callback',
+ \ 'menu': 'PlayTimeCallback',
+ \ 'info': '',
+ \ 'kind': 'v',
+ \ 'icase': 1,
+ \ }
+ \ ],
+ \ ale#completion#ParseLSPCompletions({
+ \ 'id': 226,
+ \ 'jsonrpc': '2.0',
+ \ 'result': {
+ \ 'isIncomplete': v:false,
+ \ 'items': [
+ \ {
+ \ 'detail': 'PlayTimeCallback',
+ \ 'filterText': 'next_callback',
+ \ 'insertText': 'next_callback',
+ \ 'insertTextFormat': 1,
+ \ 'kind': 6,
+ \ 'label': ' next_callback',
+ \ 'sortText': '3ee19999next_callback',
+ \ 'additionalTextEdits': [
+ \ {
+ \ 'range': {
+ \ 'start': {
+ \ 'line': 29,
+ \ 'character': 10,
+ \ },
+ \ 'end': {
+ \ 'line': 29,
+ \ 'character': 10,
+ \ },
+ \ },
+ \ 'newText': 'next_callback',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ },
+ \ })