diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-26 21:28:33 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-26 21:28:33 +0800 |
commit | 32f85a5757c6fca2529e287a58d358da54a422e4 (patch) | |
tree | 2291611aed343480e51fde73a84eee6eaaf71736 /script/core/hover/init.lua | |
parent | eb0735fd4cb9530dfa6534d7424d08155e4fb619 (diff) | |
download | lua-language-server-32f85a5757c6fca2529e287a58d358da54a422e4.zip |
fix #1092
Diffstat (limited to 'script/core/hover/init.lua')
-rw-r--r-- | script/core/hover/init.lua | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua index 9d855894..7231944a 100644 --- a/script/core/hover/init.lua +++ b/script/core/hover/init.lua @@ -40,8 +40,23 @@ local function getHover(source) local oop if vm.getInfer(source):view() == 'function' then + local defs = vm.getDefs(source) + -- make sure `function` is before `doc.type.function` + local orders = {} + for i, def in ipairs(defs) do + if def.type == 'function' then + orders[def] = i - 20000 + elseif def.type == 'doc.type.function' then + orders[def] = i - 10000 + else + orders[def] = i + end + end + table.sort(defs, function (a, b) + return orders[a] < orders[b] + end) local hasFunc - for _, def in ipairs(vm.getDefs(source)) do + for _, def in ipairs(defs) do if guide.isOOP(def) then oop = true end |