From 7360b34f9a6f9bf51a5843b065431f7f4eeef42b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 1 Jun 2021 15:23:55 +0800 Subject: generic cross files --- script/core/searcher.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'script/core/searcher.lua') diff --git a/script/core/searcher.lua b/script/core/searcher.lua index 9208032c..121e90c6 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -349,7 +349,12 @@ function m.searchRefsByID(status, uri, expect, mode) local function checkForward(id, node, field) for _, forwardID in ipairs(node.forward) do - searchID(forwardID, field) + local targetUri, targetID = noder.getUriAndID(forwardID) + if targetUri and not files.eq(targetUri, uri) then + crossSearch(status, targetUri, targetID .. (field or ''), mode) + else + searchID(targetID or forwardID, field) + end end end @@ -358,7 +363,12 @@ function m.searchRefsByID(status, uri, expect, mode) return end for _, backwardID in ipairs(node.backward) do - searchID(backwardID, field) + local targetUri, targetID = noder.getUriAndID(backwardID) + if targetUri and not files.eq(targetUri, uri) then + crossSearch(status, targetUri, targetID .. (field or ''), mode) + else + searchID(targetID or backwardID, field) + end end end @@ -471,9 +481,6 @@ function m.searchRefsByID(status, uri, expect, mode) if stepCount > 1000 then error('too large') end - if checkCrossUri(id, field) then - return - end local node = noder.getNodeByID(root, id) if node then searchNode(id, node, field) -- cgit v1.2.3