diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-01-13 18:18:09 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-01-13 18:18:09 +0800 |
commit | 7a8ffbba2af9e16225f757c7915c268125acd1e2 (patch) | |
tree | ac11f26518c4098ae3fe031d963feef44d5c9f6d | |
parent | 4be30dd4b57ac431d363dc524f375c2ccb514129 (diff) | |
download | lua-language-server-7a8ffbba2af9e16225f757c7915c268125acd1e2.zip |
fix #876
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/hover/table.lua | 12 | ||||
-rw-r--r-- | test/hover/init.lua | 2 |
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, } ]] |