summaryrefslogtreecommitdiff
path: root/server/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/core')
-rw-r--r--server/src/core/hover/name.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/server/src/core/hover/name.lua b/server/src/core/hover/name.lua
index e5880884..763083b9 100644
--- a/server/src/core/hover/name.lua
+++ b/server/src/core/hover/name.lua
@@ -17,14 +17,21 @@ return function (source)
end
if not declarat then
-- 如果声明者没有给名字,则找一个合适的名字
- local name = value:eachInfo(function (info, src)
+ local names = {}
+ value:eachInfo(function (info, src)
if info.type == 'local' or info.type == 'set' or info.type == 'return' then
if src.type == 'name' and src.uri == value.uri then
- return src[1]
+ names[#names+1] = src
end
end
end)
- return name or ''
+ if #names == 0 then
+ return ''
+ end
+ table.sort(names, function (a, b)
+ return a.id < b.id
+ end)
+ return names[1][1] or ''
end
return getName(declarat, source)