From 497f4302e9c500ada734923776d7b95d2e915009 Mon Sep 17 00:00:00 2001 From: thsid1108 Date: Sun, 14 Jun 2026 15:05:28 +0900 Subject: [PATCH] fix(file_refresh): guard against invalid buffer in TermClose autocmd 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' --- lua/claude-code/file_refresh.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/claude-code/file_refresh.lua b/lua/claude-code/file_refresh.lua index e3ae64e..41f2239 100644 --- a/lua/claude-code/file_refresh.lua +++ b/lua/claude-code/file_refresh.lua @@ -101,6 +101,7 @@ function M.setup(claude_code, config) group = augroup, pattern = '*', 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) if buf_name:match('claude%-code') then vim.o.updatetime = claude_code.claude_code.saved_updatetime