Skip to content

Commit e49ace7

Browse files
committed
close #391 definition excludes values
1 parent 5163ff8 commit e49ace7

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 1.15.1
44
* `CHG` diagnostic: `unused-local` excludes `doc.param`
5+
* `CHG` definition: excludes values, see [#391](https://github.com/sumneko/lua-language-server/issues/391)
56

67
## 1.15.0
78
`2021-2-9`

script/core/definition.lua

+13-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,19 @@ return function (uri, offset)
126126
end
127127
end
128128

129-
for _, src in ipairs(vm.getDefs(source, 0)) do
129+
local defs = vm.getDefs(source, 0)
130+
local values = {}
131+
for _, src in ipairs(defs) do
132+
local value = guide.getObjectValue(src)
133+
if value and value ~= src then
134+
values[value] = true
135+
end
136+
end
137+
138+
for _, src in ipairs(defs) do
139+
if values[src] then
140+
goto CONTINUE
141+
end
130142
local root = guide.getRoot(src)
131143
if not root then
132144
goto CONTINUE

test/definition/function.lua

+5
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ function <!x!>()
2222
end
2323
<?x?>()
2424
]]
25+
26+
TEST [[
27+
local <!f!> = function () end
28+
<?f?>()
29+
]]

0 commit comments

Comments
 (0)