summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/core/hover/table.lua12
-rw-r--r--test/hover/init.lua2
3 files changed, 15 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 35ab309c..b15d52a4 100644
--- a/changelog.md
+++ b/changelog.md
@@ -12,6 +12,7 @@
* `CHG` completion: can be triggered in `LuaDoc` and strings
* `CHG` diagnostic: smoother
* `CHG` settings `Lua.color.mode` removed
+* `FIX` [#876](https://github.com/sumneko/lua-language-server/issues/876)
* `FIX` [#879](https://github.com/sumneko/lua-language-server/issues/879)
* `FIX` [#884](https://github.com/sumneko/lua-language-server/issues/884)
* `FIX` [#885](https://github.com/sumneko/lua-language-server/issues/885)
diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua
index bd2f81ad..1310005f 100644
--- a/script/core/hover/table.lua
+++ b/script/core/hover/table.lua
@@ -122,12 +122,24 @@ local function getOptionalMap(fields)
if field.type == 'doc.field.name' then
if field.parent.optional then
local key = vm.getKeyName(field)
+ local tp = vm.getKeyType(field)
+ if tp == 'number' or tp == 'integer' then
+ key = tonumber(key)
+ elseif tp == 'boolean' then
+ key = key == 'true'
+ end
optionals[key] = true
end
end
if field.type == 'doc.type.field' then
if field.optional then
local key = vm.getKeyName(field)
+ local tp = vm.getKeyType(field)
+ if tp == 'number' or tp == 'integer' then
+ key = tonumber(key)
+ elseif tp == 'boolean' then
+ key = key == 'true'
+ end
optionals[key] = true
end
end
diff --git a/test/hover/init.lua b/test/hover/init.lua
index c12928d5..bb1d02c3 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -1644,6 +1644,7 @@ TEST [[
---@field x number
---@field y number
---@field z? number
+---@field [3]? number
local <?t?>
t.z = any
@@ -1653,6 +1654,7 @@ local t: Position {
x: number,
y: number,
z?: number,
+ [3]?: number,
}
]]