summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/completion.vim3
-rw-r--r--autoload/ale/rename.vim5
-rw-r--r--test/completion/test_lsp_completion_parsing.vader70
3 files changed, 75 insertions, 3 deletions
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index a173a0d4..b00fc6a3 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -533,6 +533,7 @@ function! ale#completion#ParseLSPCompletions(response) abort
if has_key(l:item, 'additionalTextEdits')
let l:text_changes = []
+
for l:edit in l:item.additionalTextEdits
let l:range = l:edit.range
call add(l:text_changes, {
@@ -549,7 +550,7 @@ function! ale#completion#ParseLSPCompletions(response) abort
endfor
let l:changes = [{
- \ 'fileName': expand('%:p'),
+ \ 'fileName': expand('#' . l:buffer . ':p'),
\ 'textChanges': l:text_changes,
\}]
\
diff --git a/autoload/ale/rename.vim b/autoload/ale/rename.vim
index 36a334d2..64952e63 100644
--- a/autoload/ale/rename.vim
+++ b/autoload/ale/rename.vim
@@ -90,8 +90,9 @@ function! s:getChanges(workspace_edit) abort
return a:workspace_edit.changes
elseif has_key(a:workspace_edit, 'documentChanges')
let l:document_changes = []
- if type(a:workspace_edit.documentChanges) is v:t_dict &&
- \ has_key(a:workspace_edit.documentChanges, 'edits')
+
+ if type(a:workspace_edit.documentChanges) is v:t_dict
+ \ && has_key(a:workspace_edit.documentChanges, 'edits')
call add(l:document_changes, a:workspace_edit.documentChanges)
elseif type(a:workspace_edit.documentChanges) is v:t_list
let l:document_changes = a:workspace_edit.documentChanges
diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader
index 1fdbbd96..e233c955 100644
--- a/test/completion/test_lsp_completion_parsing.vader
+++ b/test/completion/test_lsp_completion_parsing.vader
@@ -526,3 +526,73 @@ Execute(Should handle completion messages with the deprecated insertText attribu
\ ],
\ },
\ })
+
+Execute(Should handle completion messages with additionalTextEdits):
+ AssertEqual
+ \ [
+ \ {
+ \ 'word': 'next_callback',
+ \ 'menu': 'PlayTimeCallback',
+ \ 'info': '',
+ \ 'kind': 'v',
+ \ 'icase': 1,
+ \ 'user_data': json_encode({
+ \ 'codeActions': [
+ \ {
+ \ 'description': 'completion',
+ \ 'changes': [
+ \ {
+ \ 'fileName': expand('#' . bufnr('') . ':p'),
+ \ 'textChanges': [
+ \ {
+ \ 'start': {
+ \ 'line': 11,
+ \ 'offset': 2,
+ \ },
+ \ 'end': {
+ \ 'line': 13,
+ \ 'offset': 4,
+ \ },
+ \ 'newText': 'from "module" import next_callback',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ }),
+ \ },
+ \ ],
+ \ 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': 10,
+ \ 'character': 1,
+ \ },
+ \ 'end': {
+ \ 'line': 12,
+ \ 'character': 3,
+ \ },
+ \ },
+ \ 'newText': 'from "module" import next_callback',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ },
+ \ })