From 723889a4687b4a24acb66b38917beaad86675033 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Tue, 29 Jul 2025 12:34:05 +0200 Subject: [PATCH] fix(functions): properly escape percent signs in uri inputs Signed-off-by: Tomas Slusny --- lua/CopilotChat/init.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index 6e2de658..9900e62f 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -366,9 +366,12 @@ function M.resolve_functions(prompt, config) -- Resolve and process all tools for _, pattern in ipairs(matches:keys()) do - local match = matches:get(pattern) - local out = expand_tool(match.word, match.input) or pattern - prompt = prompt:gsub(vim.pesc(pattern), out, 1) + if not utils.empty(pattern) then + local match = matches:get(pattern) + local out = expand_tool(match.word, match.input) or pattern + out = out:gsub('%%', '%%%%') -- Escape percent signs for gsub + prompt = prompt:gsub(vim.pesc(pattern), out, 1) + end end return functions.parse_tools(enabled_tools), resolved_resources, resolved_tools, prompt