X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/5a4872f466ebd76ddd532bdf2798554421c53df4..fe3919e725e156d751069662d11e38f7b4791de1:/.vim/bundle/vim-lsp/test/lsp/utils/workspace_edit.vimspec diff --git a/.vim/bundle/vim-lsp/test/lsp/utils/workspace_edit.vimspec b/.vim/bundle/vim-lsp/test/lsp/utils/workspace_edit.vimspec new file mode 100644 index 00000000..5b627fee --- /dev/null +++ b/.vim/bundle/vim-lsp/test/lsp/utils/workspace_edit.vimspec @@ -0,0 +1,81 @@ +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 +