Skip to content

Commit e632470

Browse files
authored
fix(functions): if enum returns only 1 choice auto accept it (#1209)
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
1 parent cbb846f commit e632470

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

lua/CopilotChat/functions.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,14 @@ function M.enter_input(schema, source)
166166
if not schema.required or vim.tbl_contains(schema.required, prop_name) then
167167
if cfg.enum then
168168
local choices = type(cfg.enum) == 'table' and cfg.enum or cfg.enum(source)
169-
local choice = utils.select(choices, {
170-
prompt = string.format('Select %s> ', prop_name),
171-
})
169+
local choice
170+
if #choices == 1 then
171+
choice = choices[1]
172+
else
173+
choice = utils.select(choices, {
174+
prompt = string.format('Select %s> ', prop_name),
175+
})
176+
end
172177

173178
table.insert(out, choice or '')
174179
elseif cfg.type == 'boolean' then

0 commit comments

Comments
 (0)