summaryrefslogtreecommitdiff
path: root/script-beta/core/reference.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-12 18:31:51 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-12 18:31:51 +0800
commitde37c136fb0423794bdc8fcdc76eb5772d2bcaa7 (patch)
tree018e0b32a001a13b1db85fc96c3358ab0991d6e8 /script-beta/core/reference.lua
parent7eb591ee3586ba2b51460bc96dc95ac510e82409 (diff)
downloadlua-language-server-de37c136fb0423794bdc8fcdc76eb5772d2bcaa7.zip
支持引用到函数返回值
Diffstat (limited to 'script-beta/core/reference.lua')
-rw-r--r--script-beta/core/reference.lua16
1 files changed, 12 insertions, 4 deletions
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