Skip to content

Commit be1c28b

Browse files
jinzhongjiaibhagwan
authored andcommitted
fix(previewer): handle empty or invalid entries
- add validation for empty and invalid paths (".", "..") - return error message instead of parsing with `entry_to_file` - fixes crashes on Windows with live_grep
1 parent a8458b7 commit be1c28b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lua/fzf-lua/previewer/fzf.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ local grep_tag = function(file, tag)
195195
end
196196

197197
function Previewer.cmd_async:parse_entry_and_verify(entrystr)
198+
-- Handle empty or invalid entries (common on Windows with live_grep)
199+
if not entrystr or #entrystr == 0 or entrystr == "." or entrystr == ".." then
200+
local errmsg = entrystr and #entrystr > 0
201+
and string.format("'%s': Invalid entry", entrystr)
202+
or "No entry selected"
203+
return "", {}, "echo " .. libuv.shellescape(errmsg)
204+
end
205+
198206
local entry = path.entry_to_file(entrystr, self.opts)
199207
-- make relative for bat's header display
200208
local filepath = path.relative_to(entry.bufname or entry.path or "", uv.cwd())

0 commit comments

Comments
 (0)