diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-19 11:44:20 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-19 11:44:20 +0800 |
commit | 4aa6774eb322be64db441db1153326f180c8ff6a (patch) | |
tree | b091ef53fbd69f6d4557094d99ee2618601df451 /server/test/crossfile/completion.lua | |
parent | 1a889f53a34fdb2ae77bfe7189a5e00a2e723187 (diff) | |
download | lua-language-server-4aa6774eb322be64db441db1153326f180c8ff6a.zip |
class的自动完成
Diffstat (limited to 'server/test/crossfile/completion.lua')
-rw-r--r-- | server/test/crossfile/completion.lua | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/server/test/crossfile/completion.lua b/server/test/crossfile/completion.lua index c982607b..cc31ed5d 100644 --- a/server/test/crossfile/completion.lua +++ b/server/test/crossfile/completion.lua @@ -61,31 +61,6 @@ local function eq(a, b) return a == b end -local function findStartPos(pos, buf) - local res = nil - for i = pos-1, 1, -1 do - local c = buf:sub(i, i) - if c:find '%a' then - res = i - else - break - end - end - return res -end - -local function findWord(position, text) - local word = text - for i = position-1, 1, -1 do - local c = text:sub(i, i) - if not c:find '[%w_]' then - word = text:sub(i+1, position) - break - end - end - return word:match('^([%w_]*)') -end - function TEST(data) local lsp = service() local ws = workspace(lsp, 'test') @@ -99,7 +74,7 @@ function TEST(data) local uri = ws:uriEncode(fs.path(info.path)) local script = info.content if info.main then - pos = script:find('$', 1, true) + pos = script:find('$', 1, true) - 1 script = script:gsub('%$', '') mainUri = uri mainBuf = script @@ -114,9 +89,7 @@ function TEST(data) local vm = lsp:loadVM(mainUri) assert(vm) - local word = findWord(pos, mainBuf) - local startPos = findStartPos(pos, mainBuf) or pos - local result = core.completion(vm, mainBuf, startPos, word) + local result = core.completion(vm, mainBuf, pos) local expect = data.completion if expect then assert(result) |