summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-09 19:55:26 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-09 19:55:26 +0800
commit9e193c1d17d64137191c5aa9e4f39c18a795396f (patch)
treea9a56b53f43f2c44f3a7b92fde3034e926da17ac
parenta07c958b56aaa48ce2d9ad7b764df596692bedfb (diff)
downloadlua-language-server-9e193c1d17d64137191c5aa9e4f39c18a795396f.zip
转成数字再比较
-rw-r--r--script-beta/core/hover/table.lua2
-rw-r--r--test-beta/hover/init.lua14
2 files changed, 15 insertions, 1 deletions
diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua
index c6d93d03..71f90b97 100644
--- a/script-beta/core/hover/table.lua
+++ b/script-beta/core/hover/table.lua
@@ -89,7 +89,7 @@ local function buildAsConst(classes, literals)
keys[#keys+1] = k
end
table.sort(keys, function (a, b)
- return literals[a][1] < literals[b][1]
+ return tonumber(literals[a][1]) < tonumber(literals[b][1])
end)
local lines = {}
lines[#lines+1] = '{'
diff --git a/test-beta/hover/init.lua b/test-beta/hover/init.lua
index e13840a8..418008bf 100644
--- a/test-beta/hover/init.lua
+++ b/test-beta/hover/init.lua
@@ -588,6 +588,13 @@ local <?t?> = {
c = 2,
d = 3,
a = 4,
+ s = 5,
+ y = 6,
+ z = 7,
+ q = 8,
+ g = 9,
+ p = 10,
+ l = 11,
}
]]
[[
@@ -596,6 +603,13 @@ local t: {
c: integer = 2,
d: integer = 3,
a: integer = 4,
+ s: integer = 5,
+ y: integer = 6,
+ z: integer = 7,
+ q: integer = 8,
+ g: integer = 9,
+ p: integer = 10,
+ l: integer = 11,
}
]]