Files
vim-lsp-mirror/test/lsp/utils/workspace_edit.vimspec

82 lines
2.8 KiB
VimL

Describe lsp#utils#workspace_edit
Describe lsp#utils#text_edit#apply_workspace_edit
It populates location list with changes
let g:lsp_show_workspace_edits = 1
call lsp#utils#workspace_edit#apply_workspace_edit({
\ 'documentChanges': [{
\ 'textDocument': { 'uri': 'file:///path/to/file' },
\ 'edits': [
\ {
\ "range": {
\ "start": {
\ "character": 0,
\ "line": 1
\ },
\ "end": {
\ "character": 0,
\ "line": 1
\ }
\ },
\ "newText": "import java.util.LinkedList;"
\ },
\ {
\ "range": {
\ "start": {
\ "character": 0,
\ "line": 0
\ },
\ "end": {
\ "character": 0,
\ "line": 0
\ }
\ },
\ "newText": "import java.util.ArrayList;"
\ }
\ ]
\ }]})
let l:loclist = getloclist(0)
Assert Equals(len(l:loclist), 2)
Assert Equals(l:loclist[0]['lnum'], 2)
Assert Equals(l:loclist[0]['col'], 1)
Assert Equals(l:loclist[0]['text'], 'import java.util.LinkedList;')
Assert Equals(l:loclist[1]['lnum'], 1)
Assert Equals(l:loclist[1]['col'], 1)
Assert Equals(l:loclist[1]['text'], 'import java.util.ArrayList;')
end
It should not set location list if not enabled
let g:lsp_show_workspace_edits = 0
call lsp#utils#workspace_edit#apply_workspace_edit({
\ 'documentChanges': [{
\ 'textDocument': { 'uri': 'file:///path/to/file' },
\ 'edits': [
\ {
\ "range": {
\ "start": {
\ "character": 0,
\ "line": 3
\ },
\ "end": {
\ "character": 0,
\ "line": 3
\ }
\ },
\ "newText": "import java.util.LinkedList;"
\ }
\ ]
\ }]})
Assert Equals(len(getloclist(0)), 0)
End
End
End