Skip to content

[BUG] Claude Code crashes with an error if the edited buffer has unsaved changes #74

Description

@k0l350v

Bug Description

Claude Code crashes with an error if the edited buffer has unsaved changes. The error occurs when the plugin tries to initiate a diff operation

To Reproduce

Steps to reproduce the behavior:

  1. Open a file and start the Claude Code chat
  2. Ask Claude to edit the current file.
  3. While Claude is working, make manual changes to the buffer without saving it (:w not executed).
  4. The plugin attempts to run a diff and crashes.

Expected Behavior

Claude Code should handle unsaved buffer states gracefully. Specifically, before executing a diff operation, it should call checkDocumentDirty

Environment

  • Neovim version: v0.11.2
  • Claude Code CLI version: 1.0.43 (Claude Code)

Error Messages

  Error  09:28:33 notify.error ClaudeCode Error [ClaudeCode] [diff] [ERROR] Failed to setup diff operation: vim/_editor.lua:0: nvim_exec2(), line 1: Vim(edit):E37: No write since last change (add ! to override)
  Error  09:28:33 notify.error ClaudeCode Error [ClaudeCode] [diff] [ERROR] Diff setup failed for ✻ [Claude Code] ai_assistance.lua (a82377) ⧉ error: table: 0x0106cba370
  Error  09:28:33 notify.error ClaudeCode Error [ClaudeCode] [server] [ERROR] WebSocket server error: Client read error: ECONNRESET
  Error  09:28:33 notify.error ClaudeCode Error [ClaudeCode] [terminal] [ERROR] Claude exited with code 1.

Additional Context

Thank you for creating this plugin and for all the hard work you’ve put into it — it’s already proving very helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions