Skip to content

Commit 30ee7c0

Browse files
committed
fix #1451
1 parent c62b62e commit 30ee7c0

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* `FIX` [#1430](https://github.com/sumneko/lua-language-server/issues/1430)
99
* `FIX` [#1431](https://github.com/sumneko/lua-language-server/issues/1431)
1010
* `FIX` [#1446](https://github.com/sumneko/lua-language-server/issues/1446)
11+
* `FIX` [#1451](https://github.com/sumneko/lua-language-server/issues/1451)
1112

1213
## 3.5.2
1314
`2022-8-1`

script/core/completion/completion.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ local function insertDocEnum(state, pos, doc, enums)
11351135
local parent = tbl.parent
11361136
local parentName
11371137
if parent._globalNode then
1138-
parentName = parent._globalNode:getName()
1138+
parentName = parent._globalNode:getCodeName()
11391139
else
11401140
local locals = guide.getVisibleLocals(state.ast, pos)
11411141
for _, loc in pairs(locals) do

script/vm/global.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ function mt:getName()
103103
return self.name
104104
end
105105

106+
---@return string
107+
function mt:getCodeName()
108+
return (self.name:gsub(vm.ID_SPLITE, '.'))
109+
end
110+
106111
---@return string
107112
function mt:asKeyName()
108113
return self.cate .. '|' .. self.name

test/completion/common.lua

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3698,6 +3698,37 @@ f(<??>)
36983698
},
36993699
}
37003700

3701+
TEST [[
3702+
---@enum A
3703+
ppp.fff = {
3704+
x = 1,
3705+
y = 'ss',
3706+
}
3707+
3708+
---@param x A
3709+
local function f(x) end
3710+
3711+
f(<??>)
3712+
]]
3713+
{
3714+
{
3715+
label = 'ppp.fff.x',
3716+
kind = define.CompletionItemKind.EnumMember,
3717+
},
3718+
{
3719+
label = 'ppp.fff.y',
3720+
kind = define.CompletionItemKind.EnumMember,
3721+
},
3722+
{
3723+
label = '1',
3724+
kind = define.CompletionItemKind.EnumMember,
3725+
},
3726+
{
3727+
label = '"ss"',
3728+
kind = define.CompletionItemKind.EnumMember,
3729+
},
3730+
}
3731+
37013732
TEST [[
37023733
--
37033734
<??>

0 commit comments

Comments
 (0)