Skip to content

Commit c6a39a6

Browse files
committed
fix: stat files if fs_readdir doesn't provide a type (#543)
1 parent 1f7da07 commit c6a39a6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lua/oil/adapters/files.lua

+7
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ local function fetch_entry_metadata(parent_dir, entry, require_stat, cb)
301301
entry[FIELD_META] = meta
302302
end
303303

304+
-- Sometimes fs_readdir entries don't have a type, so we need to stat them.
305+
-- See https://github.com/stevearc/oil.nvim/issues/543
306+
if not require_stat and not entry[FIELD_TYPE] then
307+
require_stat = true
308+
end
309+
304310
-- Make sure we always get fs_stat info for links
305311
if entry[FIELD_TYPE] == "link" then
306312
read_link_data(entry_path, function(link_err, link, link_stat)
@@ -332,6 +338,7 @@ local function fetch_entry_metadata(parent_dir, entry, require_stat, cb)
332338
return cb(stat_err)
333339
end
334340
assert(stat)
341+
entry[FIELD_TYPE] = stat.type
335342
meta.stat = stat
336343
cb()
337344
end)

0 commit comments

Comments
 (0)