Skip to content

Commit

Permalink
close #391 definition excludes values
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Feb 18, 2021
1 parent 5163ff8 commit e49ace7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

## 1.15.0
`2021-2-9`
Expand Down
14 changes: 13 additions & 1 deletion script/core/definition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,19 @@ return function (uri, offset)
end
end

for _, src in ipairs(vm.getDefs(source, 0)) do
local defs = vm.getDefs(source, 0)
local values = {}
for _, src in ipairs(defs) do
local value = guide.getObjectValue(src)
if value and value ~= src then
values[value] = true
end
end

for _, src in ipairs(defs) do
if values[src] then
goto CONTINUE
end
local root = guide.getRoot(src)
if not root then
goto CONTINUE
Expand Down
5 changes: 5 additions & 0 deletions test/definition/function.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ function <!x!>()
end
<?x?>()
]]

TEST [[
local <!f!> = function () end
<?f?>()
]]

0 comments on commit e49ace7

Please sign in to comment.