Skip to content

Commit

Permalink
change: the file size of the directory was set to 0 by neovim.
Browse files Browse the repository at this point in the history
  • Loading branch information
obaland committed Oct 26, 2023
1 parent 0e78a23 commit 1b594d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lua/vfiler/libs/filesystem/nvim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ local function get_stat(path, name, stat, link)
return {
path = path,
name = name,
size = stat.size,
size = (stat.type == 'directory') and 0 or stat.size,
time = stat.mtime.sec,
mode = to_mode_string(stat.mode),
type = stat.type,
Expand Down Expand Up @@ -69,7 +69,7 @@ function M.scandir(dirpath)
uv.fs_stat(path, function(_, stat)
if stat then
table.insert(stats, {
path = stat.type == 'directory' and path .. '/' or path,
path = (stat.type == 'directory') and path .. '/' or path,
name = name,
stat = stat,
link = type == 'link',
Expand Down
3 changes: 1 addition & 2 deletions tests/vfiler/libs/filesystem_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ describe('filesystem $shell:' .. vim.o.shell, function()
assert.is_equal(core.path.normalize(path), stat.path)
assert.is_equal(vim.fn.getfperm(path), stat.mode)
assert.is_equal(vim.fn.getftime(path), stat.time)
-- TODO: different for each platform
--assert.is_equal(vim.fn.getfsize(path), stat.size)
assert.is_equal(vim.fn.getfsize(path), stat.size)

if core.path.is_directory(path) then
assert.is_equal('directory', stat.type)
Expand Down

0 comments on commit 1b594d5

Please sign in to comment.