fix(file_refresh): guard against invalid buffer in TermClose autocmd#132
fix(file_refresh): guard against invalid buffer in TermClose autocmd#132thsid wants to merge 1 commit into
Conversation
nvim_buf_get_name raises an error when called with a buffer id that has already been deleted by the time TermClose fires. Add an nvim_buf_is_valid check before the name lookup so Neovim exits cleanly without showing the 'Invalid buffer id' Lua callback error. Fixes the error: Lua callback: ...file_refresh.lua:104: Invalid buffer id: N stack traceback: [C]: in function 'nvim_buf_get_name'
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA single guard line is added to the ChangesTermClose Buffer Validity Guard
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
When exiting Neovim (or closing a terminal buffer), a
TermCloseautocmd infile_refresh.luacallsnvim_buf_get_name(args.buf)at line 104. By thetime the event fires the buffer may already have been deleted, causing:
Fix
Add a
nvim_buf_is_validguard before the name lookup so the callback exitsearly when the buffer is no longer valid:
This is the same defensive pattern applied to
terminal.luain #106 /commit 1952ba2.
Testing
Reproduced by opening Claude Code inside Neovim, closing the terminal split,
then quitting Neovim — the error no longer appears after this change.
Summary by CodeRabbit