-
Notifications
You must be signed in to change notification settings - Fork 156
Description
Bug Description
When using open_in_new_tab = true combined with terminal.provider = "none" (running Claude Code in an external terminal), resolving a diff (both accept AND reject) leaves behind an empty [No Name] tab. The tab is never cleaned up automatically. Each resolved diff adds another [No Name] tab.
To Reproduce
- Configure claudecode.nvim:
{
"coder/claudecode.nvim",
opts = {
terminal = { provider = "none" },
diff_opts = { open_in_new_tab = true },
},
}- Run Claude Code in a separate terminal, connect to Neovim via
/ide - Have Claude propose a file edit (a diff tab opens)
- Accept or reject the diff
- Observe: the diff tab remains as an empty
[No Name]tab
Expected Behavior
The diff tab should be fully closed after resolution, returning the user to the original tab.
Root Cause Analysis
_cleanup_diff_state() contains tab-closing logic (lines 1007-1028 in diff.lua) which switches to the new tab and runs tabclose, but wrapped in pcall — errors are silently swallowed. With terminal.provider = "none" there is no terminal buffer, so display_terminal_in_new_tab() takes the early-return path (line 219-222), creating a bare tabnew with only an empty buffer. The tab cleanup appears to fail silently in this scenario.
Multiple workaround attempts from user config (autocommands on TabEnter/TabClosed/BufEnter, monkey-patching _resolve_diff_as_rejected/deny_current_diff) were all unsuccessful.
Environment
- Neovim version: 0.11
- Claude Code CLI version: latest
- OS: macOS (Darwin 25.3.0)
- Plugin version: latest from lazy.nvim