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: Error when trying to use the command window from an oil float #378

Closed
3 tasks done
smilhey opened this issue May 17, 2024 · 1 comment
Closed
3 tasks done

bug: Error when trying to use the command window from an oil float #378

smilhey opened this issue May 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@smilhey
Copy link

smilhey commented May 17, 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-5+g50749f8df

Operating system/version

Fedora Linux 40

Describe the bug

I get an invalid in commandline window message when opening the cmdwindow for an oil float.

Error executing vim.schedule lua callback: ...local/share/nvim/lazy/oil.nvim/lua/oil/init.lua:302: E11: Invalid in command-line window; executes, CTRL-C quits
stack traceback:
[C]: in function 'nvim_win_close'
...smilhey/.local/share/nvim/lazy/oil.nvim/lua/oil/init.lua:302: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

Adding a step to check for win type in the float creation seems to do the trick :

    vim.api.nvim_create_autocmd("WinLeave", {
      desc = "Close floating oil window",
      group = "Oil",
      callback = vim.schedule_wrap(function()
        if util.is_floating_win() or vim.fn.win_gettype() == "command" then
          return
        end
        if vim.api.nvim_win_is_valid(winid) then
          vim.api.nvim_win_close(winid, true)
        end
        for _, id in ipairs(autocmds) do
          vim.api.nvim_del_autocmd(id)
        end
        autocmds = {}
      end),
      nested = true,
    })

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

Open an oil float and hit q: or : then Ctrl-f

Expected Behavior

No error message

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
            })
        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.
@smilhey smilhey added the bug Something isn't working label May 17, 2024
@stevearc
Copy link
Owner

Thanks for the report!

# 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

2 participants