aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Avramenko <andreyavr@gmail.com>2020-04-20 18:35:54 +0300
committerAndrey Avramenko <andreyavr@gmail.com>2020-04-20 18:35:54 +0300
commita0d2bfeeb5c5b344bbddf496c3259e26f0974203 (patch)
treee76a23693008f354474bccbfa983c4925b43fe5d
parente6cfc1b158506f8d2a4b598d07051b7f3de5f964 (diff)
downloadrneovim-a0d2bfeeb5c5b344bbddf496c3259e26f0974203.tar.gz
rneovim-a0d2bfeeb5c5b344bbddf496c3259e26f0974203.tar.bz2
rneovim-a0d2bfeeb5c5b344bbddf496c3259e26f0974203.zip
test: add get_completion_word test for text_doc...
...ument_completion_list_to_complete_items
-rw-r--r--test/functional/plugin/lsp_spec.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 369b826adf..7e9abaac2b 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -813,3 +813,35 @@ describe('LSP', function()
end)
end)
end)
+
+describe('LSP', function()
+ describe('completion_list_to_complete_items', function()
+ it('should choose right completion option ', function ()
+ local prefix = 'foo'
+ local completion_list = {
+ -- resolves into label
+ { label='foobar' },
+ { label='foobar', textEdit={} },
+ -- resolves into insertText
+ { label='foocar', insertText='foobar' },
+ { label='foocar', insertText='foobar', textEdit={} },
+ -- resolves into textEdit.newText
+ { label='foocar', insertText='foodar', textEdit={newText='foobar'} },
+ { label='foocar', textEdit={newText='foobar'} }
+ }
+ local completion_list_items = {items=completion_list}
+ local expected = {
+ { abbr = 'foobar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar'},
+ { abbr = 'foobar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar'},
+ { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar'},
+ { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar'},
+ { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar'},
+ { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar'},
+ }
+
+ eq(expected, exec_lua([[return vim.lsp.util.text_document_completion_list_to_complete_items(...)]], completion_list, prefix))
+ eq(expected, exec_lua([[return vim.lsp.util.text_document_completion_list_to_complete_items(...)]], completion_list_items, prefix))
+ eq({}, exec_lua([[return vim.lsp.util.text_document_completion_list_to_complete_items(...)]], {}, prefix))
+ end)
+ end)
+end)