summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
Diffstat (limited to 'script/core')
-rw-r--r--script/core/searcher.lua42
1 files changed, 18 insertions, 24 deletions
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index ec4d8b0e..f13c511f 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -4,6 +4,7 @@ local files = require 'files'
local generic = require 'core.generic'
local ws = require 'workspace'
local vm = require 'vm.vm'
+local await = require 'await'
local NONE = {'NONE'}
local LAST = {'LAST'}
@@ -179,26 +180,16 @@ function m.getObjectValue(obj)
end
local function crossSearch(status, uri, expect, mode)
- m.searchRefsByID(status, uri, expect, mode)
-end
-
-local function getLock(status, uri, expect, mode)
- local slock = status.lock
- local ulock = slock[uri]
- if not ulock then
- ulock = {}
- slock[uri] = ulock
- end
- local mlock = ulock[mode]
- if not mlock then
- mlock = {}
- ulock[mode] = mlock
+ if status.lock[uri] then
+ return
end
- if mlock[expect] then
- return false
+ status.lock[uri] = true
+ await.delay()
+ if TRACE then
+ log.debug('crossSearch', uri, expect)
end
- mlock[expect] = true
- return true
+ m.searchRefsByID(status, uri, expect, mode)
+ status.lock[uri] = nil
end
local function checkCache(status, uri, expect, mode)
@@ -223,9 +214,6 @@ function m.searchRefsByID(status, uri, expect, mode)
if not ast then
return
end
- if not getLock(status, uri, expect, mode) then
- return
- end
local root = ast.ast
local searchStep
noder.compileNodes(root)
@@ -262,7 +250,9 @@ function m.searchRefsByID(status, uri, expect, mode)
cmark[NONE] = true
searchStep(id, nil)
end
- log.debug('pop:', id, field)
+ if TRACE then
+ log.debug('pop:', id, field)
+ end
end
local function checkLastID(id, field)
@@ -644,7 +634,9 @@ function m.searchRefs(status, source, mode)
return
end
- log.debug('searchRefs:', id)
+ if TRACE then
+ log.debug('searchRefs:', id)
+ end
m.searchRefsByID(status, uri, id, mode)
end
@@ -676,7 +668,9 @@ function m.searchFields(status, source, mode, field)
if not id then
return
end
- log.debug('searchFields:', id, field)
+ if TRACE then
+ log.debug('searchFields:', id, field)
+ end
if field == '*' then
if source.special == '_G' then
if checkCache(status, uri, '*', mode) then