After opening CopilotChat, then typing gh (help) or gc (info) and closing it with q, the q keymap is not cleaned up. Pressing q a second time triggers an E5108 Lua error due to an attempt to restore a buffer to an already-invalid window.
To Reproduce
- Open CopilotChat (e.g.
:CopilotChat)
- Press
gh to show help, or gc to show info
- Press
q to close CopilotChat
- Press
q again
Expected behavior
The q keymap should be removed once the CopilotChat window is closed. Pressing q afterwards should have no effect or fall through to the default Neovim behavior.
Actual behavior
An error is thrown:
E5108: Error executing lua: ...vim/lazy/CopilotChat.nvim/lua/CopilotChat/ui/overlay.lua:119: Invalid 'window': Expected Lua number
stack traceback:
[C]: in function 'nvim_win_set_buf'
...vim/lazy/CopilotChat.nvim/lua/CopilotChat/ui/overlay.lua:119: in function 'restore'
...e/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/ui/chat.lua:163: in function <...e/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/ui/chat.lua:162>
Running :map q after closing the window confirms the stale mapping is still active:
n q * <Lua 298: ~/.local/share/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/ui/chat.lua:162>
Environment
- NVIM v0.11.6, Build type: RelWithDebInfo, LuaJIT 2.1.1772619647
- OS: macOS and Linux (reproduced on both)
- Plugin: CopilotChat.nvim (via lazy.nvim)
After opening CopilotChat, then typing
gh(help) orgc(info) and closing it withq, theqkeymap is not cleaned up. Pressingqa second time triggers anE5108Lua error due to an attempt to restore a buffer to an already-invalid window.To Reproduce
:CopilotChat)ghto show help, orgcto show infoqto close CopilotChatqagainExpected behavior
The
qkeymap should be removed once the CopilotChat window is closed. Pressingqafterwards should have no effect or fall through to the default Neovim behavior.Actual behavior
An error is thrown:
Running
:map qafter closing the window confirms the stale mapping is still active:Environment