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] Attempt to index a nil value error when press <Tab> or using bnext command with cursor in mini.files #1235

Closed bnhtho closed 1 month ago

bnhtho commented 1 month ago

Contributing guidelines

Module(s)

mini.files

Description

It seems everytime switch buffer command by using :bnext comment when cursor still in Mini.files windows, it give Attempt to index a nil value error bug

Neovim version

0.10.1

Steps to reproduce

1 . Turn on mini.files command (:lua MiniFiles.open())

  1. Open file by press L (default keybind) - Still normal
  2. Press <tab> or using :bnext command - Error happened

Expected behavior

Work normally

Actual behavior

Neovim give these error:

Error executing vim.schedule lua callback: ...hnb/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:1515: attempt to index a nil value              

stack traceback:  
...hnb/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:1515: in function 'explorer_update_cursors'                                                ...hnb/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:812: in function 'close'                                                                  
 ...hnb/.local/share/nvim/lazy/mini.files/lua/mini/files.lua:1350: in function '' vim/_editor.lua: in function <vim/_editor.lua:0>                                                                                              

image

echasnovski commented 1 month ago

Thanks for the issue!

That error is an expected behavior. The reason is that executing :bnext means that you want to show another buffer in current (i.e. from 'mini.files') window. This doesn't make much sense from workflow perspective.

Also, I can not reproduce the error from the screenshot as it is most certainly not from the latest 'mini.nvim' (line 1515 does not contain any calls). On Neovim>=0.10 it should show something like "E1513: Cannot switch buffer. 'winfixbuf' is enabled". See #1173.

Closing as it is most certainly a fixed behavior.