Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: all directory sizes show 4.1k #486

Open
3 tasks done
ndfsa opened this issue Sep 20, 2024 · 1 comment
Open
3 tasks done

bug: all directory sizes show 4.1k #486

ndfsa opened this issue Sep 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ndfsa
Copy link

ndfsa commented Sep 20, 2024

Did you check the docs and existing issues?

  • I have read the docs
  • I have searched the existing issues

Neovim version (nvim -v)

v0.11.0-dev-771+g67d6b6f27

Operating system/version

Arch Linux

Describe the bug

When using the size column, it shows "4.1k" for all directories regardless of their contents.

Screenshot from 2024-09-20 01-08-53
Screenshot from 2024-09-20 01-08-57
Screenshot from 2024-09-20 01-09-05

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. enable the size column
  2. open directory with subdirectories inside

Expected Behavior

Although it is technically correct, 4096 being the size of the inode, I think it would be better to just hide the size if it does not represent the actual size of the contents.

Directory structure

test/
test/directory1/test.txt
test/directory2/

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
        "stevearc/oil.nvim",
        config = function()
            require("oil").setup({
              
      columns = { "size", "icon" },
            })
        end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Did you check the bug with a clean config?

  • I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.
@ndfsa ndfsa added the bug Something isn't working label Sep 20, 2024
@ndfsa
Copy link
Author

ndfsa commented Sep 20, 2024

The following change to the files adapter would hide the size if the entry type is a directory.

--- a/lua/oil/adapters/files.lua
+++ b/lua/oil/adapters/files.lua
@@ -65,7 +65,7 @@ file_columns.size = {
   render = function(entry, conf)
     local meta = entry[FIELD_META]
     local stat = meta.stat
-    if not stat then
+    if not stat or stat.type == "directory" then
       return columns.EMPTY
     end
     if stat.size >= 1e9 then

Screenshot from 2024-09-20 01-14-50

Note that this only works for this adapter, as I have not yet used the others.

I can make a PR with the change

@ndfsa ndfsa changed the title bug: bug: all directory sizes show 4.1k Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant