summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-21 20:22:08 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-21 20:22:08 +0800
commit970418953e1d988080113b30b529a787e4c66bbb (patch)
tree54d7d0f6e7e1bdc155b4e8f633b88da78a3a3689 /script
parente7aa360492f0cde296281c3b2518691fbfc761e4 (diff)
downloadlua-language-server-970418953e1d988080113b30b529a787e4c66bbb.zip
fix
Diffstat (limited to 'script')
-rw-r--r--script/core/searcher.lua40
1 files changed, 30 insertions, 10 deletions
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 935f59cb..ad9605f9 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -39,7 +39,7 @@ function m.pushResult(status, mode, source, force)
return
end
local results = status.results
- local mark = status.mark
+ local mark = status.rmark
if mark[source] then
return
end
@@ -180,12 +180,30 @@ function m.getObjectValue(obj)
return nil
end
+local function checkLock(status, k1, k2)
+ local locks = status.lock
+ local lock1 = locks[k1]
+ if not lock1 then
+ lock1 = {}
+ locks[k1] = lock1
+ end
+ if lock1[NONE] then
+ return true
+ end
+ if k2 == nil then
+ k2 = NONE
+ end
+ if lock1[k2] then
+ return true
+ end
+ lock1[k2] = true
+ return false
+end
+
local function crossSearch(status, uri, expect, mode, sourceUri)
- if status.lock[uri] then
+ if checkLock(status, uri, expect) then
return
end
- status.lock[uri] = true
- --await.delay()
if TRACE then
log.debug('crossSearch', uri, expect)
end
@@ -193,7 +211,7 @@ local function crossSearch(status, uri, expect, mode, sourceUri)
status.footprint[#status.footprint+1] = ('cross search:%s %s'):format(uri, expect)
end
m.searchRefsByID(status, uri, expect, mode)
- status.lock[uri] = nil
+ --status.lock[uri] = nil
if TRACE then
log.debug('crossSearch finish, back to:', sourceUri)
end
@@ -244,6 +262,9 @@ function m.searchRefsByID(status, uri, expect, mode)
cmark = {}
mark[id] = cmark
end
+ if cmark[NONE] then
+ return
+ end
if cmark[field or NONE] then
return
end
@@ -474,10 +495,9 @@ function m.searchRefsByID(status, uri, expect, mode)
if id:sub(1, 2) ~= 'g:' then
return
end
- if status.lock[id] then
+ if checkLock(status, id, field) then
return
end
- status.lock[id] = true
local isCall = field and field:sub(2, 2) == noder.RETURN_INDEX
local tid = id .. (field or '')
if FOOTPRINT then
@@ -514,10 +534,9 @@ function m.searchRefsByID(status, uri, expect, mode)
if id:sub(1, 3) ~= 'dn:' then
return
end
- if status.lock[id] then
+ if checkLock(status, id, field) then
return
end
- status.lock[id] = true
local tid = id .. (field or '')
for _, guri in collector.each('def:' .. id) do
if not files.eq(uri, guri) then
@@ -836,7 +855,8 @@ function m.status(mode)
crossed = {},
lock = {},
results = {},
- mark = {},
+ rmark = {},
+ smark = {},
footprint = {},
count = 0,
ftag = {},