VonHeikemen / fine-cmdline.nvim

Enter ex-commands in a nice floating input.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugins throws error when entering command mode from a quick fix list

nwithers-ecr opened this issue · comments

To reproduce

nvim
:copen
q:
:q
press ':' to open buffer

I received this error

E5108: Error executing lua ...ite/pack/packer/start/nui.nvim/lua/nui/utils/autocmd.lua:380: Vim(autocmd):E680: <buffer=7>: invalid buffer number
stack traceback:
        [C]: in function 'nvim_exec'
        ...ite/pack/packer/start/nui.nvim/lua/nui/utils/autocmd.lua:380: in function 'define'
        ...m/site/pack/packer/start/nui.nvim/lua/nui/popup/init.lua:331: in function 'on'
        ...m/site/pack/packer/start/nui.nvim/lua/nui/input/init.lua:95: in function 'mount'
        ...packer/start/fine-cmdline.nvim/lua/fine-cmdline/init.lua:69: in function 'open'
        [string ":lua"]:1: in main chunk

config

vim.api.nvim_set_keymap(
  'n',
  ':',
  '<cmd>lua require("fine-cmdline").open()<CR>',
  {noremap = true}
)

nvim version

❯ nvim --version
NVIM v0.6.0-dev+600-gf71be1f87
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/nvim/parts/nvim/build/build/config -I/build/nvim/parts/nvim/build/src -I/build/nvim/parts/nvim/build/.deps/usr/include -I/usr/include -I/build/nvim/parts/nvim/build/build/src/nvim/auto -I/build/nvim/parts/nvim/build/build/include
Compiled by root@lcy01-amd64-015

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

I think I know what this is, it's not the quickfix list.

When you use q: you enter a special window called cmdwin (is like the built-in command-line, but in the form of a window).

Solutions:

  1. Hit <C-c> to close the input. And then again, to get out of the cmdwin.
  2. Another thing you could do about this is setup some autocommands so it can't happen again.
 vim.cmd([[
  autocmd CmdwinEnter * inoremap <buffer> : :
  autocmd CmdwinEnter * nnoremap <buffer> : :
]])

These restore the original behaviour of : inside cmdwin. Because cmdwin was made to execute commands, you don't need my plugin in that case.


The bug here is that cmdwin somehow executes :q and closes the input unexpectedly. This causes the input instance to lose the bufnr and that's when the error hits.

The plugin now checks if the buffer of the input is valid, if not it will create a new input instance.

The conflict between cmdwin and the input is still there, but at least now the input can recover from the error.