claude-code.nvim icon indicating copy to clipboard operation
claude-code.nvim copied to clipboard

Terminal background color stuck on red after crash

Open metrue opened this issue 11 months ago โ€ข 2 comments

Description

When pasting a large amount of text into the Claude Code input in Neovim, the Claude Code window crashes and exits immediately. Upon reopening with :ClaudeCode, the terminal buffer has a persistent red background that cannot be cleared.

Steps to Reproduce

  1. Open Neovim
  2. Run :ClaudeCode to open Claude Code
  3. Paste a very large text into the input field
  4. Claude Code crashes and exits
  5. Run :ClaudeCode again
  6. The Claude Code window now has a red background

Expected Behavior

The Claude Code window should display with normal colors after reopening, or gracefully handle large input without crashing.

Actual Behavior

  • The window crashes when large text is pasted
  • After reopening, the output area has a bright red background
  • Other Neovim windows in the same session display correctly
  • Workarounds like :bd!, reset, Ctrl-l, and terminal reset escape sequences do not fix the issue

Environment

  • OS: macOS (Darwin 24.6.0)
  • Neovim: v0.11.5
  • Claude Code version: 2.0.72

Screenshots

Image

metrue avatar Dec 18 '25 08:12 metrue

๐Ÿ“ CodeRabbit Plan Mode

Generate an implementation plan and prompts that you can use with your favorite coding agent.

  • [ ] Create Plan
Examples
You can configure auto-planning by selecting labels in the issue_enrichment configuration.

๐Ÿ”— Similar Issues

Related Issues

  • https://github.com/greggh/claude-code.nvim/issues/49
  • https://github.com/greggh/claude-code.nvim/issues/68
  • https://github.com/greggh/claude-code.nvim/issues/67
  • https://github.com/greggh/claude-code.nvim/issues/16

๐Ÿ‘ค Suggested Assignees


๐Ÿงช Issue enrichment is currently in open beta.

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

๐Ÿ’ฌ Have feedback or questions? Drop into our discord or schedule a call!

coderabbitai[bot] avatar Dec 18 '25 08:12 coderabbitai[bot]

I resolved by this changes in my nvim plugin.

diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua
index e9b71aa..82ef145 100644
--- a/lua/core/autocmds.lua
+++ b/lua/core/autocmds.lua
@@ -10,14 +10,26 @@ aucmd("BufReadPost", {
   end
 })

--- Highlight trailing whitespace
+-- Highlight trailing whitespace (skip terminal buffers)
 aucmd({ "BufWinEnter", "ColorScheme" }, {
   callback = function()
+    if vim.bo.buftype == "terminal" then
+      return
+    end
     vim.cmd("highlight ExtraWhitespace ctermbg=red guibg=red")
     vim.cmd("match ExtraWhitespace /\\s\\+$/")
   end
 })

+-- Clear match highlighting in terminal buffers
+aucmd({ "TermOpen", "TermEnter", "BufEnter" }, {
+  callback = function()
+    if vim.bo.buftype == "terminal" then
+      vim.fn.clearmatches()
+    end
+  end
+})
+
 -- Auto-create directories on save
 aucmd("BufWritePre", {
   callback = function(event)

metrue avatar Dec 18 '25 21:12 metrue