Skip to content
New issue

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

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

Already on GitHub? # to your account

bug: E11: Invalid in command-line window; <CR> executes, CTRL-C quits #390

Closed
3 tasks done
csponge opened this issue May 26, 2024 · 0 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@csponge
Copy link
Contributor

csponge commented May 26, 2024

Did you check the docs and existing issues?

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

Neovim version (nvim -v)

0.11.0 commit 4f24e1b

Operating system/version

Fedora 40

Describe the bug

When opening a file from Oil, and then opening a command window (e.g., q:) I receive this error:

Error executing vim.schedule lua callback: .../colten/.local/share/nvim/lazy/oil.nvim/lua/oil/view.lua:219: E11: Invalid in command-line window; executes, CTRL-C quits

I did some digging, and I think the issue is happening in the delete_hidden_buffers function in lua/oil/view.lua:

M.delete_hidden_buffers = function()
  local visible_buffers, hidden_buffers = get_visible_hidden_buffers()
  if not visible_buffers or not hidden_buffers or not vim.tbl_isempty(visible_buffers) then
    return
  end
  for _, bufnr in ipairs(hidden_buffers) do
    vim.api.nvim_buf_delete(bufnr, { force = true })
  end
  cache.clear_everything()
end

Calling vim.api.nvim_buf_delete throws the error. Taking a look at the old issues, it looks like it was fixed in a different part of the code base: #378. It looks like it was fixed by simply exiting before the call to close. Maybe the same solution could be applied here?

This is my first time opening an issue, so I would appreciate any feedback you have. Also, I would love to help out in fixing the issue if possible. Thanks for an awesome plugin!

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. nvim -u repro.lua
  2. Enter command :Oil
  3. Open a file
  4. Before the cleanup delay expires (2 seconds), enter command :q

You should then see the error after the cleanup delay expires.

Expected Behavior

I wouldn't expect to see anything. Oil should handle the buffers in the background.

Directory structure

N/A

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
            })
        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.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant