From c168e8853f96a8012ebdc6841ad79020b3aebafc Mon Sep 17 00:00:00 2001 From: disrupted Date: Wed, 4 Feb 2026 00:32:33 +0100 Subject: [PATCH 1/2] fix(ui): format optional grep args --- lua/opencode/ui/formatter.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/opencode/ui/formatter.lua b/lua/opencode/ui/formatter.lua index 050872ea..034b1fca 100644 --- a/lua/opencode/ui/formatter.lua +++ b/lua/opencode/ui/formatter.lua @@ -562,7 +562,12 @@ end function M._format_grep_tool(output, input, metadata) input = input or { path = '', include = '', pattern = '' } - local grep_str = string.format('%s` `%s', (input.path or input.include) or '', input.pattern or '') + local grep_str = vim + .iter({ input.path, input.include, input.pattern }) + :filter(function(s) + return s ~= nil + end) + :join('` `') M.format_action(output, icons.get('search') .. ' grep', grep_str) if not config.ui.output.tools.show_output then From 3d2c1bdf8389a11ab5340e83abec65ae55caa555 Mon Sep 17 00:00:00 2001 From: disrupted Date: Wed, 4 Feb 2026 00:35:53 +0100 Subject: [PATCH 2/2] refactor: rewrite as vim.iter as tbl_filter + concat --- lua/opencode/ui/formatter.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lua/opencode/ui/formatter.lua b/lua/opencode/ui/formatter.lua index 034b1fca..2003f157 100644 --- a/lua/opencode/ui/formatter.lua +++ b/lua/opencode/ui/formatter.lua @@ -560,14 +560,12 @@ end ---@param input GrepToolInput data for the tool ---@param metadata GrepToolMetadata Metadata for the tool use function M._format_grep_tool(output, input, metadata) - input = input or { path = '', include = '', pattern = '' } - - local grep_str = vim - .iter({ input.path, input.include, input.pattern }) - :filter(function(s) - return s ~= nil - end) - :join('` `') + local grep_str = table.concat( + vim.tbl_filter(function(part) + return part ~= nil + end, { input.path or input.include, input.pattern }), + '` `' + ) M.format_action(output, icons.get('search') .. ' grep', grep_str) if not config.ui.output.tools.show_output then