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: File list fails to render with preview open and show_hidden #563

Closed
3 tasks done
dwoznicki opened this issue Jan 20, 2025 · 1 comment
Closed
3 tasks done

bug: File list fails to render with preview open and show_hidden #563

dwoznicki opened this issue Jan 20, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@dwoznicki
Copy link

dwoznicki commented Jan 20, 2025

Did you check the docs and existing issues?

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

Neovim version (nvim -v)

NVIM v0.10.0

Operating system/version

macOS Sonoma v14.6.1

Describe the bug

When navigating up a directory tree with the preview window open, view_options.show_hidden = true, and using -, the file list will fail to render after a couple of navigations.

What is the severity of this bug?

breaking (some functionality is broken) tolerable (can work around it)

Steps To Reproduce

Here's a recording of the bug for me.

oil_nvim_render_fails_with_preview_open.mov
  1. Open Oil.
  2. Enable the preview window.
  3. Begin navigating up the directory tree with -.
  4. After pressing - a twice, the file list buffer fails to populate. This happens reliably for me, regardless of what file I'm initially on when I open Oil.

Expected Behavior

The file list should be rendered.

Directory structure

No response

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({
              -- add any needed settings here
                view_options = {show_hidden = true}
            })
        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.

Thoughts

Given that the bug only occurs when hidden files are enabled, I suspect it has something to do with the top .. entry.

EDIT 1: It appears that this autocommand runs when the list renders properly, and doesn't run when it fails to render.

vim.api.nvim_create_autocmd("BufReadCmd", {
  group = aug,
  pattern = scheme_pattern,
  nested = true,
  callback = function(params)
    load_oil_buffer(params.buf)
  end,
})

EDIT 2: When the list fails to render, the filetype is unset. Could explain why the autocommand isn't running.

EDIT 3: Confirmed that removing the ".." entry from the list solves the issue. Lowering the severity to "tolerable".

@dwoznicki dwoznicki added the bug Something isn't working label Jan 20, 2025
@stevearc
Copy link
Owner

This was a tricky one. Nested autocmds continue to be the bane of my existence. Should be fixed now!

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

2 participants