From 497f4302e9c500ada734923776d7b95d2e915009 Mon Sep 17 00:00:00 2001 From: thsid1108 Date: Sun, 14 Jun 2026 15:05:28 +0900 Subject: [PATCH 1/2] 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 From 956bb2f3fb896c4e2879975cdf583273989fce97 Mon Sep 17 00:00:00 2001 From: thsid1108 Date: Sat, 22 Aug 2026 12:36:17 +0900 Subject: [PATCH 2/2] feat(window): support position = "current" to reuse current window Opens the terminal in the current window instead of always creating a split or float, mirroring plain :terminal behavior. --- lua/claude-code/terminal.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/claude-code/terminal.lua b/lua/claude-code/terminal.lua index 0be3df1..2acf21d 100644 --- a/lua/claude-code/terminal.lua +++ b/lua/claude-code/terminal.lua @@ -187,6 +187,14 @@ local function create_split(position, config, existing_bufnr) return create_float(config, existing_bufnr) end + -- Use the current window as-is, without splitting (like plain :terminal) + if position == 'current' then + if existing_bufnr then + vim.cmd('buffer ' .. existing_bufnr) + end + return + end + local is_vertical = position:match('vsplit') or position:match('vertical') -- Create the window with the user's specified command