diff --git a/changelog.md b/changelog.md index b6caa5050..b49689f5f 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## Unreleased +* `NEW` Added `completion.maxFieldCount` which lets you increase the amount of fields to analyze before requiring more specific input ## 3.16.0 `2025-12-2` diff --git a/locale/en-us/setting.lua b/locale/en-us/setting.lua index 0c136333a..1abdf5519 100644 --- a/locale/en-us/setting.lua +++ b/locale/en-us/setting.lua @@ -178,6 +178,8 @@ config.completion.showWord.Disable = "Do not display context words." config.completion.autoRequire = "When the input looks like a file name, automatically `require` this file." +config.completion.maxFieldCount = +"Maximum number of fields to analyze for completions. When an object has more fields than this limit, completions will require more specific input to appear." config.completion.showParams = "Display parameters in completion list. When the function has multiple definitions, they will be displayed separately." config.completion.requireSeparator = diff --git a/script/config/template.lua b/script/config/template.lua index fd723db52..b9e18155a 100644 --- a/script/config/template.lua +++ b/script/config/template.lua @@ -347,6 +347,7 @@ local template = { 'Disable', }, ['Lua.completion.autoRequire'] = Type.Boolean >> true, + ['Lua.completion.maxFieldCount'] = Type.Integer >> 100, ['Lua.completion.showParams'] = Type.Boolean >> true, ['Lua.completion.requireSeparator'] = Type.String >> '.', ['Lua.completion.postfix'] = Type.String >> '@', diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index f751e53d5..b3447007e 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -565,8 +565,9 @@ local function checkFieldOfRefs(refs, state, word, startPos, position, parent, o local fields = {} local funcs = {} local count = 0 + local maxFieldCount = config.get(state.uri, 'Lua.completion.maxFieldCount') for _, src in ipairs(refs) do - if count > 100 then + if count > maxFieldCount then results.incomplete = true break end