summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-05-25 15:45:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-05-25 15:45:35 +0800
commitc586a11e9ae9b3f001c39d7f2f6762b0cf7af671 (patch)
tree396989d94b0c14b749b1393608e9d3b28ce182b3
parent50688a8001325308c30a8669783f1d0e379b463b (diff)
downloadlua-language-server-c586a11e9ae9b3f001c39d7f2f6762b0cf7af671.zip
fix #1155
-rw-r--r--changelog.md1
-rw-r--r--script/vm/ref.lua20
-rw-r--r--test/references/common.lua10
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
+]]