diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-21 14:33:17 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-21 14:33:17 +0800 |
commit | 2d3d75258b551673e2d8466cd94e4301451416a8 (patch) | |
tree | 0e1d6007ac12ccc4df1337f0c7a9061a24d2ef54 /server/src/core/completion.lua | |
parent | 6dac6c8725c002b34f0a31058a1aef9e5594d921 (diff) | |
download | lua-language-server-2d3d75258b551673e2d8466cd94e4301451416a8.zip |
优化自动完成的性能
Diffstat (limited to 'server/src/core/completion.lua')
-rw-r--r-- | server/src/core/completion.lua | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index 28a1f354..b8ccde33 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -464,16 +464,16 @@ local function searchInResult(result, source, vm, pos, callback) end end -local function searchAllWords(result, vm, callback) - if result.key == '' then +local function searchAllWords(text, vm, callback) + if text == '' then return end - if type(result.key) ~= 'string' then + if type(text) ~= 'string' then return end for source in pairs(vm.results.sources) do if source.type == 'name' then - if result.key ~= source[1] and matchKey(result.key, source[1]) then + if text ~= source[1] and matchKey(text, source[1]) then callback(source[1], CompletionItemKind.Text) end end @@ -534,7 +534,7 @@ local function clearList(list, source) end end -return function (vm, pos) +return function (vm, pos, buf) local list = {} local callback = makeList(list) local inCall = findCall(vm, pos) @@ -551,8 +551,12 @@ return function (vm, pos) if result then callback = makeList(list, source) searchInResult(result, source, vm, pos, callback) - searchAllWords(result, vm, callback) + searchAllWords(result.key, vm, callback) clearList(list, source) + else + if buf then + searchAllWords(buf:sub(pos-1, pos-1), vm, callback) + end end end if #list == 0 then |