Skip to content

Commit a7afda1

Browse files
committed
update hovering table
fields beginning with underlines are sorted to the last
1 parent 317c856 commit a7afda1

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

script/core/hover/table.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@ local function getKeyMap(fields)
128128
if ta == 'boolean' then
129129
return a == true
130130
end
131+
if ta == 'string' then
132+
if a:sub(1, 1) == '_' then
133+
if b:sub(1, 1) == '_' then
134+
return a < b
135+
else
136+
return false
137+
end
138+
elseif b:sub(1, 1) == '_' then
139+
return true
140+
else
141+
return a < b
142+
end
143+
end
131144
return a < b
132145
else
133146
return tsa < tsb

test/hover/init.lua

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,10 @@ local <?self?> = setmetatable({
504504
]]
505505
[[
506506
local self: {
507-
__index: table,
508-
__name: string = "obj",
509507
id: integer = 1,
510508
remove: function,
509+
__index: table,
510+
__name: string = "obj",
511511
}
512512
]]
513513

@@ -790,8 +790,6 @@ TEST [[
790790
]]
791791
[[
792792
(global) _G: _G {
793-
_G: _G,
794-
_VERSION: string = "Lua 5.4",
795793
arg: string[],
796794
assert: function,
797795
collectgarbage: function,
@@ -810,6 +808,8 @@ TEST [[
810808
module: function,
811809
newproxy: function,
812810
next: function,
811+
os: oslib,
812+
package: packagelib,
813813
...(+22)
814814
}
815815
]]
@@ -1850,6 +1850,23 @@ local x: {
18501850
}
18511851
]]
18521852

1853+
TEST [[
1854+
local <?x?> = {
1855+
_x = '',
1856+
_y = '',
1857+
x = '',
1858+
y = '',
1859+
}
1860+
]]
1861+
[[
1862+
local x: {
1863+
x: string = "",
1864+
y: string = "",
1865+
_x: string = "",
1866+
_y: string = "",
1867+
}
1868+
]]
1869+
18531870
TEST [[
18541871
---@class A
18551872
---@field x string

0 commit comments

Comments
 (0)