summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-23 16:15:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-23 16:15:13 +0800
commit366d163edf1373ca4f7c56ef44b77b818d9ee4f8 (patch)
tree768aef8f9a8c2f6c8dc046a019dd43a9a3d1e299 /script
parent1e7e9eba031eadfb5045a7fec01ee8519a967be6 (diff)
downloadlua-language-server-366d163edf1373ca4f7c56ef44b77b818d9ee4f8.zip
fix #567
Diffstat (limited to 'script')
-rw-r--r--script/core/noder.lua11
-rw-r--r--script/core/searcher.lua13
2 files changed, 19 insertions, 5 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 413f2007..d6d0f59a 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -988,6 +988,17 @@ function m.getLastID(id)
return lastID
end
+---获取ID的长度
+---@param id string
+---@return integer
+function m.getIDLength(id)
+ if not id then
+ return 0
+ end
+ local _, count = id:gsub(SPLIT_CHAR, SPLIT_CHAR)
+ return count + 1
+end
+
---测试id是否包含field,如果遇到函数调用则中断
---@param id string
---@return boolean
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 6c8ca60a..87769de4 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -249,7 +249,8 @@ function m.searchRefsByID(status, uri, expect, mode)
local callStack = status.callStack
- local mark = {}
+ local mark = status.flock[uri] or {}
+ status.flock[uri] = mark
local function search(id, field)
local firstID = noder.getFirstID(id)
@@ -297,7 +298,8 @@ function m.searchRefsByID(status, uri, expect, mode)
cmark = {}
mark[id] = cmark
end
- if cmark[LAST] then
+ local fieldLength = noder.getIDLength(field)
+ if cmark[LAST] and fieldLength >= cmark[LAST] then
return
end
local lastID = noder.getLastID(id)
@@ -308,7 +310,7 @@ function m.searchRefsByID(status, uri, expect, mode)
if field then
newField = newField .. field
end
- cmark[LAST] = true
+ cmark[LAST] = fieldLength
search(lastID, newField)
return lastID
end
@@ -620,10 +622,10 @@ function m.searchRefsByID(status, uri, expect, mode)
local stepCount = 0
local stepMaxCount = 1e3
- local statusMaxCount = 1e4
+ local statusMaxCount = 1e5
if mode == 'allref' or mode == 'alldef' then
stepMaxCount = 1e4
- statusMaxCount = 1e5
+ statusMaxCount = 1e6
end
function searchStep(id, field)
stepCount = stepCount + 1
@@ -853,6 +855,7 @@ function m.status(mode)
callStack = {},
crossed = {},
lock = {},
+ flock = {},
results = {},
rmark = {},
smark = {},