echasnovski / mini.nvim

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

"Invalid window id: x" #828

Closed alycklama closed 4 months ago

alycklama commented 4 months ago

Contributing guidelines

Module(s)

mini.map

Description

When working with the Quickfix window, it's easy to run into the error below:

Error detected while processing CursorMoved Autocommands for "<buffer=4>":
Error executing lua callback: .../.local/share/nvim/lazy/mini.nvim/lua/mini/map.lua:1419: Invalid window id: 1000
stack traceback:
        [C]: in function 'nvim_win_set_cursor'
        .../.local/share/nvim/lazy/mini.nvim/lua/mini/map.lua:1419: in function <.../.local/share/nvim/lazy/mini.nvim/lua/mini/map.lua:1401>

The moment you open a buffer from the Quickfix window and you then close it, you will run into the error above.

Neovim version

0.9.5

Steps to reproduce

  1. Fill the Quickfix list (e.g. via Telescope).
  2. Open a buffer from the Quickfix list, the cursor now becomes active in this new window.
  3. Close the buffer. You'll see the MiniMap becomes the active window, even though focusable is set to false in my config.
  4. Press j to move down and you'll be greeted with the error below.

Expected behavior

I expected any other buffer than the MiniMap to get the focus.

Actual behavior

Error detected while processing CursorMoved Autocommands for "<buffer=4>":
Error executing lua callback: .../.local/share/nvim/lazy/mini.nvim/lua/mini/map.lua:1419: Invalid window id: 1000
stack traceback:
        [C]: in function 'nvim_win_set_cursor'
        .../.local/share/nvim/lazy/mini.nvim/lua/mini/map.lua:1419: in function <.../.local/share/nvim/lazy/mini.nvim/lua/mini/map.lua:1401>
echasnovski commented 4 months ago

Thanks for the issue! I can reproduce. Will look into it.

alycklama commented 4 months ago

Thanks for the issue! I can reproduce. Will look into it.

Awesome, and you're welcome! I'm curious how you will approach it. I looked into this issue for an hour or so, but I'm not yet sure how to fix it yet. I can make the error go away, but the MiniMap is still selected. Ideally, it would automatically go to the next buffer, but I'm not sure if that would be the idiomatic way to handle this.

echasnovski commented 4 months ago

This should now be fixed on latest main as much as is reasonable.

There should not be an error now, but focus with present quickfix window will still go to map's floating window. This is an issue in Neovim itself and should be resolved on latest Nightly after neovim/neovim#28455. So you indirectly caused an issue fix in Neovim, thanks :)

alycklama commented 4 months ago

Thanks man! I'm glad to hear the issue is fixed already in Neovim's nightly build. Thank you for reporting it there and your quick fix!

echasnovski commented 4 months ago

Thanks man! I'm glad to hear the issue is fixed already in Neovim's nightly build. Thank you for reporting it there and your quick fix!

Issue - mine, fix - not at all, I can not take credit for it :)

alycklama commented 4 months ago

I should have been more clear, my apologies.

Retry: Thank you for the fix in mini.map! 👍