mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
Check text_edits is null (#697)
* Check text_edits is null Some Language Server return null * Add test for textEdit is null * Check additionalTextEdits is null
This commit is contained in:
@@ -102,7 +102,7 @@ function! s:on_complete_done_after() abort
|
||||
endif
|
||||
|
||||
" apply additionalTextEdits.
|
||||
if has_key(l:completion_item, 'additionalTextEdits')
|
||||
if has_key(l:completion_item, 'additionalTextEdits') && !empty(l:completion_item['additionalTextEdits'])
|
||||
let l:saved_mark = getpos("'a")
|
||||
let l:pos = getpos('.')
|
||||
call setpos("'a", l:pos)
|
||||
|
||||
@@ -43,6 +43,10 @@ function! lsp#utils#text_edit#apply_text_edits(uri, text_edits) abort
|
||||
" ((0, 0), (0, 1), "") - remove first character 'a'
|
||||
" ((0, 4), (0, 5), "") - remove fifth character 'e'
|
||||
" ((0, 2), (0, 3), "") - remove third character 'c'
|
||||
if empty(a:text_edits)
|
||||
return
|
||||
endif
|
||||
|
||||
let l:text_edits = sort(deepcopy(a:text_edits), '<SID>sort_text_edit_desc')
|
||||
let l:i = 0
|
||||
|
||||
|
||||
@@ -587,6 +587,18 @@ Describe lsp#utils#text_edit
|
||||
let l:buffer_text = s:get_text()
|
||||
Assert Equals(l:buffer_text, ['package main', '', 'import java.util.ArrayList;', '', 'public class Main {}', ''])
|
||||
End
|
||||
|
||||
It adds null
|
||||
let l:text = ['package main', '', 'import java.util.ArrayList;', '', 'public class Main {}']
|
||||
call s:set_text(l:text)
|
||||
|
||||
call lsp#utils#text_edit#apply_text_edits(
|
||||
\ expand('%'),
|
||||
\ v:null)
|
||||
|
||||
let l:buffer_text = s:get_text()
|
||||
Assert Equals(l:buffer_text, l:text + [''])
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
|
||||
Reference in New Issue
Block a user