From 25e076d4baa0a47a376d0ed647c68c56b817c88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 23 Jun 2022 19:18:58 +0800 Subject: fix completion in tablefield enums --- script/core/completion/completion.lua | 4 ++++ test/completion/common.lua | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 2f0180d2..392c21ca 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -1219,6 +1219,10 @@ local function checkEqualEnumInString(state, position, results) or parent.type == 'setindex' then checkEqualEnumLeft(state, position, parent.node, results) end + if parent.type == 'tablefield' + or parent.type == 'tableindex' then + checkEqualEnumLeft(state, position, parent, results) + end end local function isFuncArg(state, position) diff --git a/test/completion/common.lua b/test/completion/common.lua index 7c383fe4..27431000 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -3396,3 +3396,25 @@ end kind = define.CompletionItemKind.Variable, }, } + +TEST [[ +---@class A +---@field xxx 'aaa'|'bbb' + +---@type A +local t = { + xxx = ' +} +]] +{ + { + label = "'aaa'", + kind = define.CompletionItemKind.EnumMember, + textEdit = EXISTS, + }, + { + label = "'bbb'", + kind = define.CompletionItemKind.EnumMember, + textEdit = EXISTS, + }, +} -- cgit v1.2.3