diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-02-22 19:17:54 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-02-22 19:17:54 +0800 |
commit | 3981f28e23e1e7f4fb4cf44695490f0ce929a870 (patch) | |
tree | b3eb3ada1708b691e5bb4067c44244a564bdf62b | |
parent | b6dc9568d47ff4c4612c25ff3a09f62c64b46f70 (diff) | |
download | lua-language-server-3981f28e23e1e7f4fb4cf44695490f0ce929a870.zip |
fix wrong type infer of doc.field
-rw-r--r-- | script/core/hover/label.lua | 6 | ||||
-rw-r--r-- | test/completion/init.lua | 22 |
2 files changed, 24 insertions, 4 deletions
diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua index dd309c41..2fb0b14c 100644 --- a/script/core/hover/label.lua +++ b/script/core/hover/label.lua @@ -127,10 +127,8 @@ local function asDocField(source) end end local infers = {} - for _, ext in ipairs(source.extends) do - for _, infer in ipairs(vm.getInfers(ext) or {}) do - infers[#infers+1] = infer - end + for _, infer in ipairs(vm.getInfers(source.extends) or {}) do + infers[#infers+1] = infer end if not class then return ('field ?.%s: %s'):format( diff --git a/test/completion/init.lua b/test/completion/init.lua index fc9233d8..5f79ea21 100644 --- a/test/completion/init.lua +++ b/test/completion/init.lua @@ -2093,3 +2093,25 @@ local s = f() s.$ ]] (EXISTS) + +Cared['description'] = true +TEST [[ +---@class cc +---@field aaa number +---@field bbb number + +---@type cc +local t +print(t.aa$) +]] +{ + { + label = 'aaa', + kind = define.CompletionItemKind.Field, + description = [[ +```lua +field cc.aaa: number +```]] + }, +} +Cared['description'] = nil |