From de37c136fb0423794bdc8fcdc76eb5772d2bcaa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 12 Aug 2020 18:31:51 +0800 Subject: =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=BC=95=E7=94=A8=E5=88=B0=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/core/reference.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'script-beta/core/reference.lua') diff --git a/script-beta/core/reference.lua b/script-beta/core/reference.lua index e61e2940..bd4cd6b7 100644 --- a/script-beta/core/reference.lua +++ b/script-beta/core/reference.lua @@ -11,16 +11,24 @@ end local function sortResults(results) -- 先按照顺序排序 table.sort(results, function (a, b) - return a.target.start < b.target.start + local u1 = guide.getRoot(a).uri + local u2 = guide.getRoot(b).uri + if u1 == u2 then + return a.target.start < b.target.start + else + return u1 < u2 + end end) -- 如果2个结果处于嵌套状态,则取范围小的那个 - local lf + local lf, lu for i = #results, 1, -1 do local res = results[i].target - local f = res.finish - if lf and f > lf then + local f = res.finish + local uri = guide.getRoot(res).uri + if lf and f > lf and uri == lu then table.remove(results, i) else + lu = uri lf = f end end -- cgit v1.2.3