diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/vm/ref.lua | 20 | ||||
-rw-r--r-- | test/references/common.lua | 10 |
3 files changed, 27 insertions, 4 deletions
diff --git a/changelog.md b/changelog.md index 884d65db..b95c081e 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ * `FIX` [#1141](https://github.com/sumneko/lua-language-server/issues/1141) * `FIX` [#1144](https://github.com/sumneko/lua-language-server/issues/1144) * `FIX` [#1150](https://github.com/sumneko/lua-language-server/issues/1150) +* `FIX` [#1155](https://github.com/sumneko/lua-language-server/issues/1155) ## 3.2.3 `2022-5-16` diff --git a/script/vm/ref.lua b/script/vm/ref.lua index 545c294a..fbb9d015 100644 --- a/script/vm/ref.lua +++ b/script/vm/ref.lua @@ -279,10 +279,22 @@ local function searchByDef(source, pushResult) defMap[source] = true return defMap end - local defs = vm.getDefs(source) - for _, def in ipairs(defs) do - pushResult(def) - defMap[def] = true + if source.type == 'field' + or source.type == 'method' then + source = source.parent + end + defMap[source] = true + if guide.isSet(source) then + local defs = vm.getDefs(source) + for _, def in ipairs(defs) do + pushResult(def) + end + else + local defs = vm.getDefs(source) + for _, def in ipairs(defs) do + pushResult(def) + defMap[def] = true + end end return defMap end diff --git a/test/references/common.lua b/test/references/common.lua index 5217200d..47dfb099 100644 --- a/test/references/common.lua +++ b/test/references/common.lua @@ -184,3 +184,13 @@ local <~t~> --b.<~x~> = 1 --c.<!x!> = 1 --]] + +TEST [[ +---@class a +local a = { } +---@class b +local b = { } + +a.color = { 1, 1, 1 } +b.<~color~> = a.color +]] |