summaryrefslogtreecommitdiff
path: root/script/vm/infer.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-03-10 17:12:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-03-10 17:12:49 +0800
commit2178706a33e6f15a8cea567c352d9a567c38abb9 (patch)
tree36bad9d0e3f3ff6feb03ca2266060dcd89f94b1e /script/vm/infer.lua
parent75df2fd38fe75e951ea80b5f1abae8772437ae04 (diff)
downloadlua-language-server-2178706a33e6f15a8cea567c352d9a567c38abb9.zip
update
Diffstat (limited to 'script/vm/infer.lua')
-rw-r--r--script/vm/infer.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index fc60cfa5..90c10145 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -4,7 +4,12 @@ local nodeMgr = require 'vm.node'
---@class vm.infer-manager
local m = {}
+local inferSorted = {
+ ['nil'] = 100,
+}
+
local viewNodeMap = util.switch()
+ : case 'nil'
: case 'boolean'
: case 'string'
: case 'table'
@@ -59,7 +64,14 @@ function m.viewType(source)
if #array == 0 then
return 'unknown'
end
- table.sort(array)
+ table.sort(array, function (a, b)
+ local sa = inferSorted[a] or 0
+ local sb = inferSorted[b] or 0
+ if sa == sb then
+ return a < b
+ end
+ return sa < sb
+ end)
return table.concat(array, '|')
end