Description
When closing a terminal pane with Ctrl+D (sending EOF to the shell), the TermClose autocommand in file_refresh.lua crashes because the buffer is already invalid by the time the callback fires.
Error
Error in TermClose Autocommands for "*":
Lua callback: ...m/lazy/claude-code.nvim/lua/claude-code/file_refresh.lua:104: Invalid buffer id: 7
stack traceback:
[C]: in function 'nvim_buf_get_name'
...m/lazy/claude-code.nvim/lua/claude-code/file_refresh.lua:104: in function <...m/lazy/claude-code.nvim/lua/claude-code/file_refresh.lua:103>
Steps to Reproduce
- Open Neovim
- Open any terminal in a split (
:sp | te or :vs | te)
- Press
Ctrl+D to close the terminal shell
Suggested Fix
Add a buffer validity check before calling nvim_buf_get_name in the TermClose callback:
callback = function(args)
if not vim.api.nvim_buf_is_valid(args.buf) then
return
end
local buf_name = vim.api.nvim_buf_get_name(args.buf)
-- ...
end
https://github.com/greggh/claude-code.nvim/blob/main/lua/claude-code/file_refresh.lua#L103-L104
Environment
- Neovim: v0.10+
- Plugin version: latest (via lazy.nvim)
- OS: macOS
Description
When closing a terminal pane with
Ctrl+D(sending EOF to the shell), theTermCloseautocommand infile_refresh.luacrashes because the buffer is already invalid by the time the callback fires.Error
Steps to Reproduce
:sp | teor:vs | te)Ctrl+Dto close the terminal shellSuggested Fix
Add a buffer validity check before calling
nvim_buf_get_namein theTermClosecallback:https://github.com/greggh/claude-code.nvim/blob/main/lua/claude-code/file_refresh.lua#L103-L104
Environment