Skip to content

Commit 59d626d

Browse files
authored
fix: coerce Blob values to string in format_file_display (#342)
vim.json.decode returns Blobs instead of strings when the decoded value contains NUL bytes. Passing a Blob to strdisplaywidth triggers E976. Guard item.name and item.directory the same way grep_renderer.lua already guards line_content. Fixes #310
1 parent 29e6480 commit 59d626d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

lua/fff/picker_ui.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,8 +1338,11 @@ local function shrink_path(path, max_width)
13381338
end
13391339

13401340
local function format_file_display(item, max_width)
1341+
-- vim.json.decode may return Blobs for strings with NUL bytes; coerce to string.
13411342
local filename = item.name
1343+
if type(filename) ~= 'string' then filename = filename and tostring(filename) or '' end
13421344
local dir_path = item.directory or ''
1345+
if type(dir_path) ~= 'string' then dir_path = dir_path and tostring(dir_path) or '' end
13431346

13441347
if dir_path == '' and item.relative_path then
13451348
local parent_dir = vim.fn.fnamemodify(item.relative_path, ':h')

0 commit comments

Comments
 (0)