fix(picker): format: one too many spaces for default icon in results … (#594)

The default icon returned from Snacks utils already has a space for
padding.

The fix is to only append a space if there's none.


![image](https://github.com/user-attachments/assets/547ee166-ef4c-48b9-ad14-01563c630bc8)

Co-authored-by: biggybi <biggybi@pm.me>
This commit is contained in:
Biggybi 2025-01-17 22:36:06 +01:00 committed by GitHub
parent 47ea3280e8
commit d7f727f673
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,7 +37,8 @@ function M.filename(item, picker)
if picker.opts.icons.files.enabled ~= false then
local icon, hl = Snacks.util.icon(name, cat)
ret[#ret + 1] = { icon .. " ", hl, virtual = true }
local padded_icon = icon:sub(-1) == " " and icon or icon .. " "
ret[#ret + 1] = { padded_icon, hl, virtual = true }
end
local dir, file = path:match("^(.*)/(.+)$")