From ba90011a1481b9b9314a7cebbb319f7472ea25a8 Mon Sep 17 00:00:00 2001 From: Wen <48466898+hifanx@users.noreply.github.com> Date: Sun, 19 Oct 2025 16:03:43 +0800 Subject: [PATCH] fix(scratch): use icon[1] when icon is a table to avoid table.concat error (#2242) ## Description Problem: opts.icon can be a table {icon, icon_hl} but the code inserts opts.icon directly into filekey and later does table.concat(filekey, "|"). That crashes when an element is a table. Fix: use the first element of opts.icon when opts.icon is a table (fallback to opts.icon or ""). ## Related Issue(s) N/A ## Screenshots This happens when scratch.opts.icon is a table per documentation image --- lua/snacks/scratch.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/snacks/scratch.lua b/lua/snacks/scratch.lua index 2c3ed786..cc9e3075 100644 --- a/lua/snacks/scratch.lua +++ b/lua/snacks/scratch.lua @@ -180,7 +180,7 @@ function M.open(opts) local filekey = { opts.filekey.count and tostring(vim.v.count1) or "", - opts.icon or "", + (type(opts.icon) == "table" and opts.icon[1]) or opts.icon or "", opts.name:gsub("|", " "), opts.filekey.cwd and svim.fs.normalize(assert(uv.cwd())) or "", branch,