summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/collector.lua25
-rw-r--r--script/core/searcher.lua5
2 files changed, 28 insertions, 2 deletions
diff --git a/script/core/collector.lua b/script/core/collector.lua
index 5ccbcaee..2f29fc37 100644
--- a/script/core/collector.lua
+++ b/script/core/collector.lua
@@ -1,4 +1,5 @@
local scope = require 'workspace.scope'
+local ws = require 'workspace'
local collect = {}
local subscribed = {}
@@ -88,4 +89,28 @@ function m.each(uri, name)
return getNext
end
+--- 迭代某个名字的引用订阅
+---@param uri uri
+---@param name string
+function m.eachRef(uri, name)
+ local nameCollect = collect[name]
+ if not nameCollect then
+ return DUMMY_FUNCTION
+ end
+ ---@type scope
+ if scope.getFolder(uri) then
+ return m.each(uri, name)
+ end
+
+ local curi, value
+ local function getNext()
+ curi, value = next(nameCollect, curi)
+ if not curi then
+ return nil, nil
+ end
+
+ return value, curi
+ end
+ return getNext
+end
return m
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 6c832155..558dc96b 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -27,6 +27,7 @@ local getUri = guide.getUri
local getRoot = guide.getRoot
local ceach = collector.each
+local ceachref = collector.eachRef
local getState = files.getState
@@ -844,7 +845,7 @@ function m.searchRefsByID(status, suri, expect, mode)
::CONTINUE::
end
else
- for _, guri in ceach(suri, id) do
+ for _, guri in ceachref(suri, id) do
if crossed[guri] then
goto CONTINUE
end
@@ -880,7 +881,7 @@ function m.searchRefsByID(status, suri, expect, mode)
::CONTINUE::
end
else
- for _, guri in ceach(suri, id) do
+ for _, guri in ceachref(suri, id) do
if crossed[guri] then
goto CONTINUE
end