summaryrefslogtreecommitdiff
path: root/server/src/core/hover/name.lua
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-15 16:47:21 +0800
committersumneko <sumneko@hotmail.com>2019-04-15 16:47:21 +0800
commit12373b0f4e0b44ed98c9eaa8ce0c6b8c3f3697b5 (patch)
tree36b197259121c6ea0166cd35d16337776b757b5b /server/src/core/hover/name.lua
parent31cb7ffd42ba378b1d8f7688c81a0af8562d2d86 (diff)
downloadlua-language-server-12373b0f4e0b44ed98c9eaa8ce0c6b8c3f3697b5.zip
find_name 排序结果
Diffstat (limited to 'server/src/core/hover/name.lua')
-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)