diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-10-11 16:19:08 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-10-11 16:19:08 +0800 |
commit | e82c09fd0b06e8d4ca872759fb6bb4d50506dd6a (patch) | |
tree | a126cdd41e72a1a45db6cdf875c2c0d021a2ce1c /test | |
parent | 8ec593e83fff0ba00466361cdee5dece07c5d98e (diff) | |
download | lua-language-server-e82c09fd0b06e8d4ca872759fb6bb4d50506dd6a.zip |
fix #1567
Diffstat (limited to 'test')
-rw-r--r-- | test/tclient/init.lua | 2 | ||||
-rw-r--r-- | test/tclient/tests/same-prefix.lua | 57 |
2 files changed, 59 insertions, 0 deletions
diff --git a/test/tclient/init.lua b/test/tclient/init.lua index 6f861142..eff77d8a 100644 --- a/test/tclient/init.lua +++ b/test/tclient/init.lua @@ -11,4 +11,6 @@ require 'tclient.tests.change-workspace-folder' require 'tclient.tests.jump-source' require 'tclient.tests.load-relative-library' require 'tclient.tests.hover-set-local' +require 'tclient.tests.same-prefix' + require 'tclient.tests.build-meta' diff --git a/test/tclient/tests/same-prefix.lua b/test/tclient/tests/same-prefix.lua new file mode 100644 index 00000000..bc2a1f9b --- /dev/null +++ b/test/tclient/tests/same-prefix.lua @@ -0,0 +1,57 @@ +local lclient = require 'lclient' +local fs = require 'bee.filesystem' +local util = require 'utility' +local furi = require 'file-uri' +local ws = require 'workspace' +local files = require 'files' +local scope = require 'workspace.scope' + +local rootPath = LOGPATH .. '/same-prefix' +local rootUri = furi.encode(rootPath) + +for _, name in ipairs { 'ws', 'ws1' } do + fs.create_directories(fs.path(rootPath .. '/' .. name)) +end + +---@async +lclient():start(function (client) + client:registerFakers() + + client:initialize { + rootPath = rootPath, + rootUri = rootUri, + workspaceFolders = { + { + name = 'ws', + uri = rootUri .. '/ws', + }, + { + name = 'ws1', + uri = rootUri .. '/ws1', + }, + } + } + + ws.awaitReady(rootUri .. '/ws') + ws.awaitReady(rootUri .. '/ws1') + + files.setText(rootUri .. '/ws1/test.lua', [[ + ]]) + + files.setText(rootUri .. '/ws/main.lua', [[ +require '' + ]]) + + local comps1 = client:awaitRequest('textDocument/completion', { + textDocument = { + uri = rootUri .. '/ws/main.lua', + }, + position = { + line = 0, + character = 9, + }, + }) + for _, item in ipairs(comps1.items) do + assert(item.label ~= 'test') + end +end) |