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

[Question] Edit tool: Diff view only opens for single-line edits, not multi-line - is this by design?

Open elfenlieds7 opened this issue 3 months ago • 6 comments

Environment

  • Claude Code Version: VSCode Extension (latest)
  • Platform: Windows
  • IDE: VSCode

Observed Behavior

When using the Edit tool, I've noticed inconsistent behavior in how file changes are presented:

Single-line edits:

  • Opens VSCode's built-in diff editor
  • Shows side-by-side comparison (red/green highlighting)
  • Requires approval in the diff view

Multi-line edits:

  • Does NOT open the diff editor
  • Only shows an approval dialog with text diff
  • No visual side-by-side comparison in the editor

Example

Single-line change (opens diff editor):

old: version = "0.5.3"
new: version = "0.5.4"

Multi-line change (no diff editor, only dialog):

old: 
target-version = "py311"
line-length = 100

new:
target-version = "py312"
line-length = 120

Question

Is this behavior by design or is there a configuration option to control it?

Expected behavior: I would expect all Edit tool operations to open the diff editor view for consistency, regardless of the number of lines changed.

Current behavior: Only single-line edits open the diff editor; multi-line edits bypass it.

Configuration Checked

I've reviewed my .claude/settings.local.json (only contains permissions config) and couldn't find any settings related to diff view behavior. The official documentation doesn't mention this either.

Is there a setting I'm missing, or is this the intended UX design?

Thank you!

elfenlieds7 avatar Nov 09 '25 16:11 elfenlieds7

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/8660
  2. https://github.com/anthropics/claude-code/issues/8509

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Nov 09 '25 16:11 github-actions[bot]

Update: Found the exact trigger condition

After further testing, I've identified the precise behavior:

Diff editor OPENS when:

  • The old_string parameter in the Edit tool contains a single line
  • This works even with multiple independent Edit calls in parallel

Diff editor does NOT open when:

  • The old_string parameter contains multiple lines (regardless of the distance between changes)

Test Results

# ✅ Opens diff editor
Edit(old_string="version = '0.5.3'", new_string="version = '0.5.4'")

# ✅ Both open diff editors (two separate Edit calls)
Edit(old_string="version = '0.5.3'", new_string="version = '0.5.4'")
Edit(old_string="line-length = 100", new_string="line-length = 120")

# ❌ Does NOT open diff editor (multi-line old_string)
Edit(
    old_string="version = '0.5.3'\n...270 lines...\nline-length = 100",
    new_string="version = '0.5.4'\n...270 lines...\nline-length = 120"
)

The last case is especially problematic - when changes are far apart in the file, reviewing them in the editor with proper context would be most valuable, but that's exactly when the diff view fails to open.

This appears to be a bug in the VSCode extension's edit presentation logic.

elfenlieds7 avatar Nov 09 '25 16:11 elfenlieds7

Thanks for flagging the potential duplicates. I've reviewed both:

  • #8660: Reports diff preview not showing, with "String not found" errors
  • #8509: Reports diff window no longer opening in VSCode 2.0

While these issues describe similar symptoms, this issue provides additional diagnostic value:

  1. Root cause identification: I've identified the exact trigger condition - the diff editor only opens when old_string contains a single line, not when it contains multiple lines.

  2. Reproducible test cases: I've documented specific examples showing when the diff opens vs. when it doesn't, which could help developers fix the underlying issue.

  3. Different manifestation: The other issues report diff never showing or being replaced by chat window diffs. This issue shows inconsistent behavior - single-line edits work correctly, multi-line edits fail.

This could be:

  • The same underlying bug with a more precise diagnosis
  • A related but distinct issue in the edit presentation logic

Suggestion: Keep this issue open as it provides specific technical details that could help fix #8660 and #8509. Once fixed, all three should be resolved together.

Let me know if you'd like me to cross-reference these issues or if you prefer to consolidate them.

elfenlieds7 avatar Nov 09 '25 16:11 elfenlieds7

Update: Clarification

I just realized this issue is specific to the Claude for VS Code Extension, not the Claude Code CLI.

When using Claude Code CLI in the VS Code terminal (with /ide properly configured to VS Code), the Edit tool behavior is as expected - all edits (both single-line and multi-line) consistently open the diff editor view.

The inconsistent behavior described in this issue only occurs when using the Claude for VS Code Extension directly.

Please let me know if this should be tracked in a different location for the VS Code Extension, or if it's appropriate to continue here. Apologies for the initial confusion about which product was affected.

elfenlieds7 avatar Nov 15 '25 02:11 elfenlieds7

Using Cli version for a while. Dont understand how to fix it on Win11

gelnor avatar Nov 19 '25 10:11 gelnor

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 20 '25 10:12 github-actions[bot]