Skip to content

[BUG] Leftover [No Name] tab after diff resolve with open_in_new_tab and terminal.provider = none #208

@phorn1

Description

@phorn1

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

  1. Configure claudecode.nvim:
{
  "coder/claudecode.nvim",
  opts = {
    terminal = { provider = "none" },
    diff_opts = { open_in_new_tab = true },
  },
}
  1. Run Claude Code in a separate terminal, connect to Neovim via /ide
  2. Have Claude propose a file edit (a diff tab opens)
  3. Accept or reject the diff
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions