summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2024-06-05 18:37:24 +0800
committer最萌小汐 <sumneko@hotmail.com>2024-06-05 18:37:24 +0800
commitc0de8e657bf8685691078b6a367a03a46997bf9c (patch)
tree734badf1ca90f22e116e108291752bda74526761 /script
parent9498df4eee86545ac29df2ff3d701e57448585ad (diff)
downloadlua-language-server-c0de8e657bf8685691078b6a367a03a46997bf9c.zip
`FIX` Autocompletion for enum values ​​is not available in some cases
Diffstat (limited to 'script')
-rw-r--r--script/core/completion/completion.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index 5c55c16b..242bf449 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -1357,6 +1357,13 @@ local function insertEnum(state, pos, src, enums, isInArray, mark)
kind = define.CompletionItemKind.Function,
insertText = insertText,
}
+ elseif src.type == 'doc.enum' then
+ ---@cast src parser.object
+ if vm.docHasAttr(src, 'key') then
+ insertDocEnumKey(state, pos, src, enums)
+ else
+ insertDocEnum(state, pos, src, enums)
+ end
elseif isInArray and src.type == 'doc.type.array' then
for i, d in ipairs(vm.getDefs(src.node)) do
insertEnum(state, pos, d, enums, isInArray, mark)
@@ -1364,11 +1371,7 @@ local function insertEnum(state, pos, src, enums, isInArray, mark)
elseif src.type == 'global' and src.cate == 'type' then
for _, set in ipairs(src:getSets(state.uri)) do
if set.type == 'doc.enum' then
- if vm.docHasAttr(set, 'key') then
- insertDocEnumKey(state, pos, set, enums)
- else
- insertDocEnum(state, pos, set, enums)
- end
+ insertEnum(state, pos, set, enums, isInArray, mark)
end
end
end