summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-12 17:19:03 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-12 17:19:03 +0800
commitac9e09ffb7e0dddf7e48725ce59733c53a7443b3 (patch)
tree8635af9b4e8b8b770bbb565eddeb48494dfbb5f3 /script/core
parentd066720039568bab0126bc058faf23588500562a (diff)
downloadlua-language-server-ac9e09ffb7e0dddf7e48725ce59733c53a7443b3.zip
improve completion speed
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion/completion.lua11
1 files changed, 3 insertions, 8 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index c457a14a..6edfac91 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -645,14 +645,11 @@ local function checkCommon(state, word, position, results)
for _, data in ipairs(keyWordMap) do
used[data[1]] = true
end
- if not config.get(state.uri, 'Lua.completion.workspaceWord')
- or #word >= 2 then
- results.complete = true
- end
if config.get(state.uri, 'Lua.completion.workspaceWord') and #word >= 2 then
local myHead = word:sub(1, 2)
for uri in files.eachFile() do
if #results >= 100 then
+ results.incomplete = true
break
end
if myUri == uri then
@@ -702,6 +699,7 @@ local function checkCommon(state, word, position, results)
end
for str, offset in state.lua:gmatch '([%a_][%w_]+)()' do
if #results >= 100 then
+ results.incomplete = true
break
end
if #str >= 3
@@ -716,9 +714,6 @@ local function checkCommon(state, word, position, results)
end
end
end
- if #results >= 100 then
- results.complete = false
- end
end
local function checkKeyWord(state, start, position, word, hasSpace, afterLocal, results)
@@ -1973,7 +1968,7 @@ end
---@async
local function completion(uri, position, triggerCharacter)
- local state = files.getState(uri)
+ local state = files.getLastState(uri) or files.getState(uri)
if not state then
return nil
end