Skip to content

Commit

Permalink
fix #1451
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Aug 12, 2022
1 parent c62b62e commit 30ee7c0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* `FIX` [#1430](https://github.com/sumneko/lua-language-server/issues/1430)
* `FIX` [#1431](https://github.com/sumneko/lua-language-server/issues/1431)
* `FIX` [#1446](https://github.com/sumneko/lua-language-server/issues/1446)
* `FIX` [#1451](https://github.com/sumneko/lua-language-server/issues/1451)

## 3.5.2
`2022-8-1`
Expand Down
2 changes: 1 addition & 1 deletion script/core/completion/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ local function insertDocEnum(state, pos, doc, enums)
local parent = tbl.parent
local parentName
if parent._globalNode then
parentName = parent._globalNode:getName()
parentName = parent._globalNode:getCodeName()
else
local locals = guide.getVisibleLocals(state.ast, pos)
for _, loc in pairs(locals) do
Expand Down
5 changes: 5 additions & 0 deletions script/vm/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ function mt:getName()
return self.name
end

---@return string
function mt:getCodeName()
return (self.name:gsub(vm.ID_SPLITE, '.'))
end

---@return string
function mt:asKeyName()
return self.cate .. '|' .. self.name
Expand Down
31 changes: 31 additions & 0 deletions test/completion/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3698,6 +3698,37 @@ f(<??>)
},
}

TEST [[
---@enum A
ppp.fff = {
x = 1,
y = 'ss',
}
---@param x A
local function f(x) end
f(<??>)
]]
{
{
label = 'ppp.fff.x',
kind = define.CompletionItemKind.EnumMember,
},
{
label = 'ppp.fff.y',
kind = define.CompletionItemKind.EnumMember,
},
{
label = '1',
kind = define.CompletionItemKind.EnumMember,
},
{
label = '"ss"',
kind = define.CompletionItemKind.EnumMember,
},
}

TEST [[
--
<??>
Expand Down

0 comments on commit 30ee7c0

Please sign in to comment.