From bd9f7aecf1f0c2fb12ca9af356e27de308e2c5d4 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Mon, 28 Jul 2025 16:44:15 +0200 Subject: [PATCH] fix(functions): properly resolve defaults for diagnostics Closes #1200 Signed-off-by: Tomas Slusny --- lua/CopilotChat/config/functions.lua | 4 ++-- lua/CopilotChat/functions.lua | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lua/CopilotChat/config/functions.lua b/lua/CopilotChat/config/functions.lua index 07b11573..1644a03f 100644 --- a/lua/CopilotChat/config/functions.lua +++ b/lua/CopilotChat/config/functions.lua @@ -258,12 +258,12 @@ return { diagnostics = { group = 'copilot', - uri = 'neovim://diagnostics/{scope}', + uri = 'neovim://diagnostics/{scope}/{severity}', description = 'Collects code diagnostics (errors, warnings, etc.) from specified buffers. Helpful for troubleshooting and fixing code issues.', schema = { type = 'object', - required = { 'scope' }, + required = { 'scope', 'severity' }, properties = { scope = { type = 'string', diff --git a/lua/CopilotChat/functions.lua b/lua/CopilotChat/functions.lua index 8a28ca81..6cc287bb 100644 --- a/lua/CopilotChat/functions.lua +++ b/lua/CopilotChat/functions.lua @@ -136,8 +136,7 @@ function M.parse_input(input, schema) local prop_names = sorted_propnames(schema) -- Map input parts to schema properties in sorted order - local i = 1 - for _, prop_name in ipairs(prop_names) do + for i, prop_name in ipairs(prop_names) do local prop_schema = schema.properties[prop_name] local value = not utils.empty(parts[i]) and parts[i] or nil if value == nil and prop_schema.default ~= nil then @@ -145,10 +144,6 @@ function M.parse_input(input, schema) end result[prop_name] = value - i = i + 1 - if i > #parts then - break - end end return result