[BUG] Edit preview/diff not showing in VSCode extension UI when confirming changes
UPDATE: This bug is still present as of 8. March 2026...
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using the Claude Code VSCode extension, edit previews are not visible when confirming code changes. The UI prompts me to confirm changes but only shows the file in its current state, without displaying the diff/preview of what will be changed.
- Confirmation dialog appears
- File opens in current state without showing the diff
- No preview of what will change is visible
- Changes work correctly once confirmed, but I can't see what I'm confirming
The same functionality works perfectly when running Claude Code via terminal in VSCode. The diff preview displays as expected.
What Should Happen?
Should show a diff/preview of the proposed changes before confirmation, similar to the terminal CLI version.
Error Messages/Logs
This is visible in vscode dev tools console, not sure if relevant. It says failed to apply edit even though It doesn't fail if I accept it.
index.js:1008 Uncaught (in promise) Error: String not found in file. Failed to apply edit.
at uX.readMessages (index.js:1008:30299)
localProcessExtensionHost.ts:280 Extension Host
localProcessExtensionHost.ts:281 Claude Code stderr: [DEBUG] "Permission suggestions for Edit: [\n {\n \"type\": \"setMode\",\n \"mode\": \"acceptEdits\",\n \"destination\": \"session\"\n }\n]"
Steps to Reproduce
- Open VSCode with Claude Code extension
- Request code changes via the extension UI
- Observe confirmation prompt - diff preview is not visible
- Compare with terminal CLI version where diff shows correctly
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.1 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
VSCode Version: 1.104.2 (e3a5acfb517a443235981655413d566533107e92 x64)
52 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Same issue with me
Same issue
Same, was good even yesterday
Guys you are supposed to upvote this if you have the same issue, not comment "same"
Looks like this hasnt been fixed. Is there a work around?
I use the terminal in visual studio rather than the claude code extension. That works like before.
Could we bring this to the developers’ attention? The terminal version works, but it has some visual issues, and the extension is currently unavailable for me.
I use terminal and the diff is suddenly disappearing. But the claude code plugin is still working
Same issue here. Any workarounds?
Upvoted.
This also happens here.
Shows diff editor when using Linux, VS Code, Claude Code Extension.
Shows diff editor when using Windows, VS Code, Claude Code Terminal.
Doesn't show diff editor when using Windows, VS Code, Claude Code Extension. Or to be more precise, it shows very sporadically, like once in 50 edits or more.
Same here automatically switched from showing me a diff in the UI to a terminal view.
Any update on this? This makes Claude Code essentially unuseable on Windows with VSCode
(cross posted in this thread)
I'm putting my two cents in here in the hopes it will help others to understand if they're having a similar experience, especially those who aren't super techy. For clarification, I am using the Claude Code VS Code Extension (v 2.0.75) in VS Code (v 1.107.1) on a Windows 11 machine. Everything is up to date.
Here is the exact version of the issue I'm running into. For the past few weeks, the Claude Code extension in VS Code rarely opens changes in the VS Code diff editor.
Here is how it used to be, where it would show the inline diff changes, but it would pop open the diff editor window.
<img width="2560" height="1368" alt="Image" src="https://github.com/user-attachments/assets/066858e9-c80d-46da-b9d0-1b79ec7e655c" />
This is MUCH more useful, especially when you're working with big chunks of code or text.
Here is how it looks now:
<img width="2560" height="1368" alt="Image" src="https://github.com/user-attachments/assets/2c24b5b7-dbad-448a-b54a-69029f31b91e" />
The inline diff editor only shows what's being changed, so you lose all context. Also, it doesn't show line numbers, so you can't even really find it all that easily on your own.
I have tried any number of fixes, including turning off Windows Defender and Google Drive syncing. I have rolled back the version of the CC extension. Play around with different diff editor settings in VS Code, all to no avail. As far as I can tell, I've tried just about every recommended fix in Github.
I am not a coder and didn't start using Claude Code until right after the VS Code extension was launched, so using the CLI is annoying and a new learning curve I wasn't planning on dealing with. But, it seems to work with the diff editor like normal. It's just a pain and slows me down.
Probable Root Cause: CRLF Line Endings + Multi-line String Matching
I think I have identified the technical root cause of this issue. The diff preview fails specifically when:
\r\n) line endings (default on Windows)oldStringcontains newline characters (multi-line replacements)The extension uses
\nin the search string, but CRLF files contain\r\n, causing the "String not found in file" error.---
Complete Reproduction with Logs
Environment:
---
<details>
<summary><b>Detailed Test Scenarios</b></summary>
<br>
Test File (
test-diff-preview.md):Logs captured from VS Code Output panel (View → Output → Claude Code) during testing.
✅ Scenario 1: Single → Single (CRLF) - Works
Prompt: "Replace 'Line A' with 'Line A modified'"
Log:
Result: Diff preview appears ✅
---
✅ Scenario 2: Single → Multi-line (CRLF) - Works
Prompt: "Replace 'Line A modified' with two lines: 'Line A modified' and 'Line A2 added'"
Log:
Result: Diff preview appears ✅ (newString with
\ndoesn't cause issues)---
❌ Scenario 3: Multi-line → Single (CRLF) - FAILS
Prompt: "Replace both 'Line A modified' and 'Line A2 added' with just 'Line A'"
Log:
Error:
Result: No diff preview, only Yes/No permission prompt ❌
---
✅ Scenario 4: Multi-line → Single (LF) - Works
File converted to LF line endings (click "CRLF" in status bar → "LF" → save)
Prompt: "Replace 'Line A' and 'Line B' with 'Lines A and B merged'"
Log:
Result: Diff preview appears ✅
---
</details>
Test Results
| Scenario | File EOL | oldString | newString | Diff Preview | Error |
|----------|----------|-----------|-----------|--------------|-------|
| 1 | CRLF | single-line | single-line | ✅ Works | - |
| 2 | CRLF | single-line | multi-line | ✅ Works | - |
| 3 | CRLF | multi-line | single-line | ❌ Fails |
String not found in file|| 4 | LF | multi-line | single-line | ✅ Works | - |
---
Root Cause
The extension always uses LF (
\n) in theoldStringparameter, regardless of the file's actual line ending style. When searching in CRLF files:"Line A\nLine B""Line A\r\nLine B"Key Finding: Only
oldStringwith newlines causes issues.newStringcan contain\nwithout problems.---
Addressing Issues in the Thread
<details>
<summary><b>OP's error message about string not found in file</b></summary>
The error message that the OP encountered in the VS Code dev tools console
is precisely the error that occurs when the extension attempts to match multi-line
oldStringpatterns. The extension searches for strings containing LF (\n) line endings, but when the file actually contains CRLF (\r\n), the string match fails.</details>
<details>
<summary><b>@edsonbrusque's comment about environment patterns</b></summary>
As noted by @edsonbrusque, the diff editor exhibits a pattern:
This issue occurs predominantly on Windows where CRLF is the default line ending, and it's intermittent because it only manifests during multi-line
oldStringedits.</details>
---
Suggested Fixes
oldString\nand\r\n---
Workaround
Convert files to LF line endings:
Note: This may conflict with Git/EditorConfig settings that enforce CRLF on Windows.
@4nds `s fix worked for me.
been having this issue on windows and changing to LF works
@4nds You are a GENIUS! Such a simple little fix but it worked! This has been hampering me for weeks. THANK YOU!
If you're dense like me and couldn't figure out what he was talking about at first, open the file which is to be changed and the CRLF/LF toggle is at the bottom right (it's not on the chat window, where I was looking).
<img width="1189" height="160" alt="Image" src="https://github.com/user-attachments/assets/d19cbfda-1df0-4a52-87e2-ab97bbb35ecc" />
For Claude Code to work smoothly again with the fix in mind - do you have to update every file in your codebase to use the new line endings?
@dancherb i don
t think that works.s not viable to use it that way, i`ve been dealing with the lack of diff and using github copilotAt least for me in windows every time i save a file it goes back to CRLF so it
It doesn't switch back for me. I don't know if it's the file type I'm working in (almost always MD files) but once I switch it, it's saved. You can also set the default to LF by changing this setting to
\n.<img width="872" height="364" alt="Image" src="https://github.com/user-attachments/assets/08068c85-feb2-4346-8368-ed08612bbe04" />
Since using this fix, I have had no issues with this working; I'm so happy! Hope you all can get a fix on your end.
This issue is still present in extension version 2.1.25. @4nds seems to have found the root cause. It's tedious to have to update the line endings in every file that I want to see diffs for, so hopefully this gets a permanent fix soon.
Yes can confirm this bug is present on version 2.1.27 also, Windows 11. The workaround by @4nds of converting CRLF to LF made it work for me, but that is not always possible, and it did put me off using Claude for a long time as the first impression is that the claude vscode extension just does not support nice editor diffs like copilot.
I also have this issue
Same issue, workaround works, but its off putting when other agents and extensions dont have that issue
None of the workarounds stated above worked for me, but running VS Code as an admin did the trick.
Same issue just today
Facing the same issue even though I am in LF mode
Update: Still happening as of March 2026, and the CRLF fix doesn't help in all cases. (Or maybe it stopped working entirely?)
I have a file with LF line endings and diffs still don't show. After digging into the VSCode Developer Tools console, I'm seeing a different error when Claude Code tries to make an edit:
You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorkerThe full stack trace points to computeDiff failing because the Monaco web worker isn't initialized. So at least in some cases the root cause isn't CRLF at all. The extension's webview isn't setting up MonacoEnvironment before it tries to compute the diff, so the diff view never renders.
This means there are probably two separate bugs here: the CRLF string matching issue that others have reported, and this Monaco worker initialization issue. Switching to LF fixes the first one but not the second.
This is also documented in #14788 by @jdavidbush, who found that the Monaco worker error is file-type specific. Simpler formats like .md, .txt, and .css work fine, but language-specific file types like .js, .php, and in my case, .dart fail because they require a language worker that isn't being configured correctly in the webview context. The theory is that Monaco needs MonacoEnvironment.getWorkerUrl or getWorker to be defined before initializing workers for these file types, and the extension's webview isn't doing that.
This should be a relatively simple bugfix if anyone at anthropic cares?
Here's a patch script that Claude helped me create to fix the diff preview tab not opening when the file contains CRLFs and a multi-line edit is done.
This script applies two patches to the extension's extension.js file, to convert all CRLFs to LFs before attempting to show the diff tab. This doesn't just force the diff tab to be shown, it normalizes both the existing and new code to use only LFs before the comparison is made for the edit, which allows the diff tab to be shown without an error.
Instructions are included for patching both the Windows extension for editing local files, and the Linux-based extension that's used when editing files via SSH. The script auto-detects the location of the newest Claude Code extension and then backs up the extension.js file before applying the two patches to it. All that's needed after running the script is to reload VS Code, and then the diff preview tab should start working as normal again. See the readme file in the project below for the full instructions.
This is version 1.0.0, with most of the credit going to Claude for figuring out what to patch, as well as how to find the location of the code to patch by using pattern matching instead of minified variable names that may change when the extension is updated. Give it a try and let us know how it works for you. It finally fixed the problem on both Windows and SSH for me.
https://github.com/russellgilbert/claude-code-diff-fix
I bought the $20 plan only to run across this issue in a few hours.
AI Agents still aren't at a stage where I would trust them autonomously, so prompt --> review --> accept --> prompt --> repeat is my primary flow of working.
But this bug makes it unusable in VS Code on Windows. Cannot see the diff at all. Sad that Anthropic has been ignoring such a core issue for 6 months.
You might try my patch script that I mentioned above. It completely fixed the problem for me.
https://github.com/russellgilbert/claude-code-diff-fix
Russell
Can confirm this works well.
Tested it with a few files. It does work as expected, thanks!
This worked. thanks!
<img width="296" height="141" alt="Image" src="https://github.com/user-attachments/assets/ae580bf6-0ee5-4711-b9e6-69faccd3cd8f" />
Changing the current file to LF also works. Anyway, it would be nice if Anthropic fixed this.
With 2 more days of weekend development, I see this no longer works reliably. It worked properly for my 1st project, which is when I applied this patch and reloaded VS Code window but then about 12 hours later when I opened a new window for another project, there is stopped working.
One person previously said
I'm facing the same. Even after changing to LF, I see it doesn't work 100% of the time. With CRLF, it works approximately 20% of the time & with LF it works like 80%, but not 100% of the time. I'm not sure what causes it to work in some cases but not others, seems very random to me.
Either way, I won't be renewing my Claude subscription next month & will switch to Copilot plans and use Sonnet/Opus that way.
@downloaderfan wrote:
Sorry to hear that - I see they just released extension versions 2.1.75 and 2.1.76. I tested my patch script on both of them and it still works ok, but note that you do need to run the script and reload VS Code again each time the extension updates.
node \path\to\patch_claude_crlf.jsor via ssh:
node /path/to/patch_claude_crlf.jsCtrl+Shift+P→ "Developer: Reload Window"Let me know if you're having some other problem. Thanks.
@russellgilbert
Yeah, I guess that's the compromise we must make. Either run it once & disable updates, missing out of all (including significant) updates or run it once after every update. Considering that updates usually happen in the background silently, that would mean running it daily once using something like Task Scheduler assuming a person wants to set something once & forget about the issue.
@downloaderfan wrote:
Great idea! And a cron job on the Linux/SSH side.
when this will be fixed properly?
Well, being that this was initially posted on October 1st, 2025, and still hasn't been fixed... There's really no telling.
| Well, being that this was initially posted on October 1st, 2025, and still hasn't been fixed... There's really no telling.
But we have been told Claude Code can easily do it :) :)
I posted about my patch script in the Claude Code Discord so hopefully a dev will see it and fix the issue officially.
https://discord.com/channels/1072196207201501266/1483842348273242223
A few things that have helped others with this issue:
Workaround 1 — Use the integrated terminal instead of Native UI:
Open VSCode's terminal (
Ctrl+\) and runclaude` directly. The CLI mode shows full diffs inline. This gives you the same diff preview you'd get in a standalone terminal.Workaround 2 — Enable verbose output for review before confirming:
Add to your CLAUDE.md:
This makes Claude print the diff as text in the chat, so you can review it even without the VSCode diff viewer working.
Workaround 3 — Use git diff after each change:
Set up a PostToolUse hook to show diffs after every Edit:
This won't show inline diffs, but you'll see which files changed after each edit. You can then use
git diff <file>in the terminal to review specifics.Workaround 4 — Check VSCode settings:
Some users found that the diff viewer depends on these VSCode settings:
Also try: Command Palette → "Preferences: Open Settings (JSON)" and search for any Claude Code extension settings related to diff rendering.
If anyone's looking for an alternative — I built a VSCode extension that sidesteps this entirely by not using Claude Code's built-in diff. It watches file writes and shows inline diffs with per-hunk Accept/Discard.
https://github.com/molon/hunkwise
<img width="2338" height="2054" alt="Image" src="https://github.com/user-attachments/assets/c59be747-0138-4fe2-8348-8ee4ca9845aa" />
I don't know if this can help anyone else but I found that after updating to
2.1.107I could no longer see the suggested code edits. It turned out that if I increased the size of the panel containing Claude Code in the editor, the edit suggestions would suddenly show up. The bug seems to be that they don't show at all if the window is too small.So this is still broken.
Have you considered that this is a core feature?
I'm having to use git to keep track of edits claude code is making. All I see in the chat is " Edit [filename]", clicking on that take me to the file, no diff. Copilot shows diff for changes it makes, codex shows diffs for changes it makes. Claude code edits files and doesn't show you what edits it has made??
This bug is quite annoying. Or is it a feature and no more diff is supported?
I created a patch script to fix the diff preview tab not opening when the file contains CRLFs and a multi-line edit is done.
This script applies three patches to the extension's extension.js file, to convert all CRLFs to LFs before attempting to show the diff tab. This doesn't just force the diff tab to be shown, it normalizes both the existing and new code to use only LFs before the comparison is made for the edit, which allows the diff tab to be shown without an error.
Instructions are included for patching both the Windows extension for editing local files, and the Linux-based extension that's used when editing files via SSH. The script auto-detects the location of the newest Claude Code extension and then backs up the extension.js file before applying the two patches to it. All that's needed after running the script is to reload VS Code, and then the diff preview tab should start working as normal again. See the readme file in the project below for the full instructions.
Give it a try and let us know how it works for you. It finally fixed the problem on both Windows and SSH for me.
https://github.com/russellgilbert/claude-code-diff-fix
Confirming this is still present. My symptom: the chat panel shows a stat-only summary line like "Added 7 lines" under the Edit message, but zero diff content renders anywhere — not inline in the message, not in a separate side-by-side tab. The file is edited correctly once confirmed; I just can't see what changed beforehand.
One data point that might help narrow the cause: I run multiple concurrent Claude Code sessions (VS Code chat panel + separate terminal sessions using
/ideto connect). I initially suspected the single-connection limit on the "ide" MCP server ("Only one Claude Code instance can be connected to VS Code at a time") was starving the chat panel of its diff-rendering capability. I tested this directly — disconnected all other terminal sessions from/ideand reloaded the VS Code window (Developer: Reload Window) so the chat panel would have exclusive access to the connection — and the diff preview was still completely absent afterward. So in my case at least, it doesn't appear to be simple connection contention between concurrent instances; the underlying rendering issue persists even with a clean, single-instance connection.VS Code extension, chat panel (not terminal mode — terminal mode with
/ideshows diffs fine, consistent with other reports here).Follow-up to my earlier comment: the panel-width workaround mentioned by @martin-raspberry above fixed it for me too, and I want to add a bit more precision on what it does/doesn't fix.
Before: Chat panel docked narrow (sidebar width) — zero diff content rendered, only a stat line like "Added N lines" under the Edit message.
After: widened the Chat panel to roughly half my laptop screen — the diff now renders inline in the chat message. This is the same fix others reported, confirmed.
One distinction worth noting: this restores the inline diff, not the separate native side-by-side tab. I also use the extension's Terminal UI mode (
claudeCode.useTerminal) +/idein a different session, which does give the true side-by-side tab reliably — so it seems like there may be two related-but-distinct rendering paths here: (1) whether any diff content renders at all in the chat panel (fixed by panel width), and (2) whether it opens as a separate side-by-side tab vs. inline (seems tied to which UI mode / whether/ideis connected). Just flagging in case that's a useful distinction for whoever's debugging this — inline-in-chat-panel and side-by-side-tab may be two different code paths, not one bug with two symptoms.Claude Code 2.1.202, macOS, VS Code extension.