Skip to content

[BUG] Error after accepting edits in diff view #33

Closed
@nikklassen

Description

@nikklassen

Bug Description

When an edit is accepted with <leader>da I see the error message Error: String not found in file. Failed to apply edit. from Claude and then it says something like "Oh I see the edit is already applied"

To Reproduce

Steps to reproduce the behavior:

  1. Start Claude Code integration with :ClaudeCode
  2. Ask it to make an edit
  3. Accept the edit with <leader>da
  4. See error

Expected Behavior

No error message is reported

Environment

  • Neovim version: HEAD
  • Claude Code CLI version: 1.0.19
  • OS: Ubuntu 24.04
  • Plugin version: HEAD

Error Messages

If applicable, add error messages or logs.

[ClaudeCode] [terminal] [DEBUG] Using native terminal provider
[ClaudeCode] [server] [DEBUG] Server module loaded with instance ID: 81478
[ClaudeCode] [terminal] [DEBUG] Using native terminal provider
[ClaudeCode] [terminal] [DEBUG] Using native terminal provider
[ClaudeCode] [terminal] [DEBUG] Using native terminal provider
[ClaudeCode] [terminal] [DEBUG] Using native terminal provider
[ClaudeCode] [server] [DEBUG] WebSocket client connected: uv_tcp_t: 0x59fd175b9490
[ClaudeCode] [server] [DEBUG] Received tools/call. Tool:  closeAllDiffTabs  Arguments:  vim.empty_dict()
[ClaudeCode] [server] [DEBUG] Response - tools/call closeAllDiffTabs: {
  error = {
    code = -32601,
    message = "Tool not found: closeAllDiffTabs"
  }
}
[ClaudeCode] [server] [DEBUG] Received tools/call. Tool:  getDiagnostics  Arguments:  vim.empty_dict()
[ClaudeCode] [server] [DEBUG] Response - tools/call getDiagnostics: {
  result = {
    diagnostics = {}
  }
}
[ClaudeCode] [server] [DEBUG] Received tools/call. Tool:  getDiagnostics  Arguments:  vim.empty_dict()
[ClaudeCode] [server] [DEBUG] Response - tools/call getDiagnostics: {
  result = {
    diagnostics = {}
  }
}
[ClaudeCode] [server] [DEBUG] Received tools/call. Tool:  getDiagnostics  Arguments:  vim.empty_dict()
[ClaudeCode] [server] [DEBUG] Response - tools/call getDiagnostics: {
  result = {
    diagnostics = {}
  }
}
[ClaudeCode] [server] [DEBUG] Received tools/call. Tool:  openDiff  Arguments:  {
  new_file_contents = "..."
  new_file_path = ".../main.go",
  old_file_path = ".../main.go",
  tab_name = "✻ [Claude Code] main.go (155712) ⧉"
}
[ClaudeCode] [tools] [DEBUG] Wrapping openDiff in coroutine for blocking behavior
[ClaudeCode] [tools] [DEBUG] About to resume coroutine for openDiff
[ClaudeCode] [diff] [DEBUG] Starting diff setup for tab_name: ✻ [Claude Code] main.go (155712) ⧉
[ClaudeCode] [diff] [DEBUG] Setup step 1: Finding existing buffer or window for .../main.go
[ClaudeCode] [diff] [DEBUG] File existence check - old_file_exists: true is_new_file: false path: .../main.go
[ClaudeCode] [diff] [DEBUG] Found existing buffer 1 for file .../main.go
[ClaudeCode] [diff] [DEBUG] Found window 1000 containing buffer 1
[ClaudeCode] [diff] [DEBUG] Creating new content buffer
[ClaudeCode] [diff] [DEBUG] Creating diff view from window 1000 is_new_file: false
[ClaudeCode] [diff] [DEBUG] Creating diff view from window 1000
[ClaudeCode] [diff] [DEBUG] Enabled diff mode on original file in window 1000
[ClaudeCode] [diff] [DEBUG] Created split window 1004 with new buffer 5
[ClaudeCode] [diff] [DEBUG] Diff view setup complete - original window: 1000 new window: 1004
[ClaudeCode] [diff] [DEBUG] Registering autocmds
[ClaudeCode] [diff] [DEBUG] Storing diff state
[ClaudeCode] [diff] [DEBUG] Setup completed successfully for ✻ [Claude Code] main.go (155712) ⧉
[ClaudeCode] [diff] [DEBUG] Diff setup completed successfully for ✻ [Claude Code] main.go (155712) ⧉ - about to yield and wait for user action
[ClaudeCode] [diff] [DEBUG] About to yield and wait for user action
[ClaudeCode] [tools] [DEBUG] Coroutine resume returned - success: true status: suspended
[ClaudeCode] [tools] [DEBUG] Coroutine is suspended - tool is blocking, will respond later
[ClaudeCode] [server] [DEBUG] Tool is blocking - setting up deferred response
[ClaudeCode] [server] [DEBUG] Handler returned deferred response - storing for later
[ClaudeCode] [server] [DEBUG] Setting up deferred response for coroutine: thread: 0x78d37848f058
[ClaudeCode] [server] [DEBUG] Storage happening in module instance: 81478
[ClaudeCode] [server] [DEBUG] Stored response sender in global table for coroutine: thread: 0x78d37848f058
[ClaudeCode] [terminal] [DEBUG] Using native terminal provider
[ClaudeCode] [diff] [DEBUG] Writing accepted changes to file: .../main.go
[ClaudeCode] [diff] [DEBUG] Successfully wrote changes to .../main.go
[ClaudeCode] [diff] [DEBUG] Reloading buffer 1 for file: .../main.go
[ClaudeCode] [diff] [DEBUG] Successfully reloaded buffer 1
[ClaudeCode] [diff] [DEBUG] Resuming coroutine for saved diff ✻ [Claude Code] main.go (155712) ⧉
[ClaudeCode] [diff] [DEBUG] Resolution callback called for coroutine: thread: 0x78d37848f058
[ClaudeCode] [diff] [DEBUG] User interaction detected, got result: {
  content = { {
      text = "FILE_SAVED",
      type = "text"
    }, {
      text = "..."
      type = "text"
    } }
}
[ClaudeCode] [diff] [DEBUG] Coroutine completed successfully with result: {
  content = { {
      text = "FILE_SAVED",
      type = "text"
    }, {
      text = "..."
      type = "text"
    } }
}
[ClaudeCode] [diff] [DEBUG] Calling global response sender for coroutine: thread: 0x78d37848f058
[ClaudeCode] [server] [DEBUG] Deferred response triggered for coroutine: thread: 0x78d37848f058
[ClaudeCode] [diff] [DEBUG] Diff saved but not closed - waiting for close_tab command
[ClaudeCode] [server] [DEBUG] Received tools/call. Tool:  close_tab  Arguments:  {
  tab_name = "✻ [Claude Code] main.go (155712) ⧉"
}
[ClaudeCode] [close_tab handler called with params: {
  tab_name = "✻ [Claude Code] main.go (155712) ⧉"
}] [DEBUG] 
[ClaudeCode] [Attempting to close tab: ✻ [Claude Code] main.go (155712) ⧉] [DEBUG] 
[ClaudeCode] [Detected diff tab - closing diff view] [DEBUG] 
[ClaudeCode] [Cleaned up diff state for '✻ [Claude Code] main.go (155712) ⧉' due to: diff tab closed after save] [DEBUG] 
[ClaudeCode] [Successfully closed diff for tab: ✻ [Claude Code] main.go (155712) ⧉] [DEBUG] 
[ClaudeCode] [server] [DEBUG] Response - tools/call close_tab: {
  result = {
    message = "Tab closed: ✻ [Claude Code] main.go (155712) ⧉"
  }
}
[ClaudeCode] [server] [DEBUG] Received tools/call. Tool:  close_tab  Arguments:  {
  tab_name = "✻ [Claude Code] main.go (155712) ⧉"
}
[ClaudeCode] [close_tab handler called with params: {
  tab_name = "✻ [Claude Code] main.go (155712) ⧉"
}] [DEBUG] 
[ClaudeCode] [Attempting to close tab: ✻ [Claude Code] main.go (155712) ⧉] [DEBUG] 
[ClaudeCode] [Detected diff tab - closing diff view] [DEBUG] 
[ClaudeCode] [Diff not found for tab: ✻ [Claude Code] main.go (155712) ⧉] [DEBUG] 
[ClaudeCode] [server] [DEBUG] Response - tools/call close_tab: {
  result = {
    message = "Tab closed: ✻ [Claude Code] main.go (155712) ⧉ (diff not found)"
  }
}
[ClaudeCode] [server] [DEBUG] Received tools/call. Tool:  getDiagnostics  Arguments:  {
  uri = "file://.../main.go"
}
[ClaudeCode] [server] [DEBUG] Response - tools/call getDiagnostics: {
  result = {
    diagnostics = {}
  }
}

Additional Context

It seems that <leader>da is undocumented, I found it because I was hunting around for a way to not focus the diff pane. I think the accept flow is fine with this key, but the error message makes me think Claude doesn't like it

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