echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
5.24k stars 190 forks source link

mini.files: error when manually quitting a window with `:close`/`:quit` #477

Closed Subjective closed 1 year ago

Subjective commented 1 year ago

Contributing guidelines

Module(s)

mini.files

Description

While I don't see why anyone would do this, manually quitting the files window with :quit or :close throws the following error:

E5108: Error executing lua: ...shua/.local/share/min/lazy/mini.files/lua/mini/files.lua:1250: Invalid window id: 1045
stack traceback:
        [C]: in function 'nvim_win_get_buf'
        ...shua/.local/share/min/lazy/mini.files/lua/mini/files.lua:1250: in function 'explorer_refresh'
        ...shua/.local/share/min/lazy/mini.files/lua/mini/files.lua:823: in function 'go_in'
        ...shua/.local/share/min/lazy/mini.files/lua/mini/files.lua:1811: in function <...shua/.local/share/min/lazy/mini.files/lua/mini/files.lua:1809>

Neovim version

NVIM v0.10.0-dev-aab06ed

Steps to reproduce

  1. nvim -u repro.lua
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "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", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.rtp:prepend(lazypath)

-- install AstroNvim
require("lazy").setup({
    { "echasnovski/mini.files", opts = {} },
}, { root = root .. "/plugins" })

Expected behavior

For all the mini.files popup windows to close gracefully.

Actual behavior

image

In some situations, it's no longer possible to open mini.files properly with require("mini.files").open().

echasnovski commented 1 year ago

Thanks for creating this!

The proper way to close 'mini.files' is by pressing config.mappings.close key (q by default). I'll see what I can do to support :quite/:close as well.

echasnovski commented 1 year ago

Although I couldn't reproduce the error you describe, I think this now should be resolved on main branch as there is tracking of lost focus. If you still have this issues, please leave a comment.