[BUG] missing ide_selection and wrong ide_opened_file in VSCode extension
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?
Description: The Claude Code VSCode extension has two context synchronization bugs that prevent proper interaction with selected code and file states:
Bug 1: Selected code is not transmitted to Claude
When selecting code in the editor and asking Claude to work with it, Claude does not receive the selection context.
Actual behavior:
User selects code in editor
User asks Claude to "optimize the selected code"
Claude does not receive any <ide_selection> tags
Claude reports it cannot see any selected code
Bug 2: Stale "opened file" state
Claude receives <ide_opened_file> context for files that are not actually open in the IDE.
Actual behavior:
Files that were previously opened but are now closed still appear in <ide_opened_file> tags
Claude reports seeing files as "opened" when they are not actually open in the editor
Environment
OS: Linux (WSL2, Ubuntu 24.04)
VSCode version: latest
Claude Code extension version: latest
What Should Happen?
Expected behavior:
User selects code in editor
User asks Claude to "optimize the selected code"
Claude receives <ide_selection> tags with the selected code content
Claude can process the selected code
Expected behavior:
When a file is closed in the IDE, Claude should not receive <ide_opened_file> context for it
The opened file state should accurately reflect current IDE state
Error Messages/Logs
Steps to Reproduce
Use the latest VSCode and latest Claude extension on a python file.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
1.0.128 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
This problem appeared with the newest VSCode extension.
Selection was working fine before.
48 Comments
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Perhaps #7221 covers the ide_selection problem, but does not cover the stale ide_opened_file problem so there is overlap but this is not a full duplication.
I see a similar issue with 2.x Vscode plugin, resolved by reverting the plugin to 1.0.127
One extra quirk I noticed was that I saw this behaviour with all the files in the currently opened vscode folder. If I opened a file outside of this, the the context feature worked fine. It also worked for editor log windows and it would work for a short period for newly created files.
FWIW I'm seeing this issue for a very large repo on MacOS 26.0.1 / VSCode 1.104.3 / Claude Code 2.0.8, but not for a smaller repo. both
ide_selectionandide_opened_filejump around, sometimes to the correct file but usually to older references.Actually, this appears to be specific to python files, and only in certain repos. In the large repo I reproed this in, all other files show up as expected in
ide_selectionandide_opened_file, but python files do not. Python files work in other repos. I was able to repro this with all extensions other than claude code disabled.I can confirm that this is failing in a large python repo that I work out of, but the extension functions properly in several other repos (one written in golang, another in typescript, etc.). Something about python code seems to contribute to the issue.
It is not specific to python, I'm seeing this issue for c# (.cs) files as well as others. In case it is relevant, I'm using Vscode for remote dev, windows ide working on Ubuntu remote.
+1, seeing this on remote dev, but not local
seeing same problem, remote dev, large repo, different file types
For files which don't show up in
ide_opened_file, I also don't get autocomplete when I try to \@-mention them - perhaps this is a related bug?After the last extension update:
ide_selection is no longer sent to the Claude extension in the native UI
It still works when switching to the terminal UI though.
<img width="1758" height="1126" alt="Image" src="https://github.com/user-attachments/assets/e69397d9-9df1-4c3a-94d3-44ddf5983657" />
Same thing. Details:
pyproject.tomlis correctly handled.pyproject.toml, select some lines, switch back to a Python file, then open a new Claude tab, that new Claude tab sees the samepyproject.tomlselection that the first Claude tab saw.I didn't find anything related in the Console or in the Output panel's Claude, Python, Python LSP, main, or extension host sections.
Environment:
Have the same issue. This is pretty disruptive, so I'm surprised this isn't being prioritized higher.
Environment:
Same exact issue happening with me
Confirming this is happening to me only in a larger python repository.
Can you check if you have those files excluded from your VSCode search or are in your .gitignore? We do not add the context from exclusions that you have added to VSCode
I can confirm I have this issue across all files, they are definitely not in .gitignore.
-- Claude Code extension --
Version: 2.0.59
-- VS Code --
Version: 1.106.3 (Universal)
Electron: 37.7.0
ElectronBuildId: 12781156
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 25.0.0
Can you show me a screenshot of the input box?
If you have accidentally clicked on the name of the file, it might toggle off the context attachment and it will show up like this. Clicking on it again should toggle it on
<img width="251" height="91" alt="Image" src="https://github.com/user-attachments/assets/8c1e68b9-f3a6-4342-82fb-c7554016d39f" />
It might not just be
.gitignore, we also honor the file and search exclusion settings in VSCode:<img width="463" height="389" alt="Image" src="https://github.com/user-attachments/assets/7ce8a286-f610-40cb-b1c2-123215f1ae94" />
No it's definitely a bug, see the following:
<img width="1062" height="792" alt="Image" src="https://github.com/user-attachments/assets/d2ae2d3c-60f0-4035-9eaf-91687e55b0ea" />
I have enabled context attachment and the previously-opened
README.mdis showing up instead of the Python file my cursor is in right now. I haven't configured any exclusion lists.This is with Claude Code 2.0.59.
When you press @ , can you reference that python file? Do you have any
.ignorefiles in your directory that's excluding python? also, are you running on linux, mac, or windows?It's something specific to the setup, since it's still working for many other users. I'm throwing ideas out, but since I can't reproduce it, will need to know your setup more to figure out exactly what's wrong.
Since ur having trouble reproducing it, to add more datapoints, hundreds of people that I work with all with similar setups to mine (above), experience this issue. I have heard reports of this intermittently working for them.
Note that our setup involves remote development.
This is happening to me in a small python repo (4
.pyfiles) in a dev<img width="1053" height="713" alt="Image" src="https://github.com/user-attachments/assets/2df955b6-4851-4f38-a11f-f053ba147592" />
container. Does not happening a c++ devcontainer.
Likely irrelevant, but this is my Dockerfile
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.
For everyone who is seeing this, are you using devcontainers or remote workspaces somehow?
No
There's something in the specific env setup that's causing this, but there's no way to tell with the limited info here aside from it just not working.
Here's some debug info that might help:
claudein an external terminal can you @-mention that file there?Can you check if those files/patterns are found in
.gitignore,.ignore,git/info/exclude,~/.gitignore_global?I'm hitting this, too. For me, no python files show up at all in the autocomplete list when I type
@in the claude extension window, but all the other files in my repo do. I've mostly moved on to using Claude from iTerm2, but would still appreciate having this fixed, or have some other way of telling claude about specific lines I have selected in VSCode. Currently I use "Copy GitHub Permalink" from the context menu and then chop off all the github bits, which is obv unwieldy.FWIW I do see the filename referenced in the Claude Code extension UI (fastapi.py here) but the specific selected lines aren't surfaced, and the
@autocomplete is missing it and the rest of the python files as previously mentioned.<img width="275" height="101" alt="Image" src="https://github.com/user-attachments/assets/7b74131c-282e-4176-a36e-08cee5cee60e" />
None of these files are in any of those - they're all in source control.
are all your python files under a specific file path compared to other files? can you share that file path?
trying to nail down exactly why it's not working for just python files.
No, they are spread throughout the repo, intermingled with non-python files that the Claude extension can see. This is a relatively large monorepo.
Can you share the
pwdof it (sanitize away any username or stuff). There are some default exclusion paths such as**/node_modules/**and**/dist/**and**/build/**that might be ignoring them by defaultIt is not just python files, for me it is broken for all files.
If I open just subfolder, it works fine. But if I open entire repo with that subfolder, selection no longer works in the same file.
My setup, vscode running on macbook, remote dev using ssh in vscode to linux machine, large repo(200k-500k files).
Unsubscribe
On Thu, Jan 8, 2026 at 12:51 PM Yuriy Kvartsyanyy @.***>
wrote:
For me, this manifests for all python files across our primarily python monorepo - these are not in any exclusion paths, all of these files are in source control. The repo has 5k+ python files in it. This issue does not manifest for me in smaller repos with a handful of python files. In those,
ide_selectionworks as expected for python files.I'm also experiencing this issue on macOS.
Environment
Observations
Current IDE Lock Files
I have multiple lock files in
~/.claude/ide/:/Users/.../bangkok-sdk/Users/.../order_placer/Users/.../bangkok-sdkPerhaps the multiple client connections are causing conflicts with the
ide_selectioncontext?Additional Issue
I also noticed that subagents (spawned via Task tool) auto-deny
WebSearchwith error:Even though
WebSearchis explicitly allowed in~/.claude/settings.local.json. Not sure if this is related or a separate bug.Note that this issue is ONLY about the VSCode GUI extension, not the one from
/ide. That's likely another issue so please file another bug for this.For those who are seeing this with just the python files, can you run
rg --files --follow --hiddenin that directory to see you can see python files in that search?rgis the ripgrep search we use under the hood (same for VSCode too)I've had the same issue off and on with the vscode claude extension seeing my file but not the selected text and being unable to @ mention python files. I was able to find the issue by renaming my .gitignore file which cleared the issue fully. I then had claude disable any patterns that were unused.
The issue was:
*.py,cover
Claude built my gitignore so its not something i needed but here's what it said:
"Most likely. The comma in the glob pattern could confuse the extension's parser into matching *.py files"
Confirmed to the be the cause by uncommenting the problematic line and using "Developer:Reload Window"
Commenting it out again and a subsequent reload and the issue is resolved again.
If Reload is not performed then only some files are able to have text selection. No rhyme or reason as far as i can tell. It happens during both commenting and uncommenting. Only a Reload will fully reset to all readable or not readable
+1 — still happening on macOS with the latest extension version.
Even after closing ALL editor tabs, the last-active file is still shown as context being sent to Claude Code. The file no longer exists in any open tab, yet I still have to manually dismiss it from the context. The opened file state clearly doesn't reflect the actual IDE state.
Having the same issue with the latest versions of VSCode and Claude Code
Note that uv's default
.gitignoreis:So
*.py[oc]could be a suspect. I saw the bug in projects that had either this.gitignoreor GitHub's, which contains*.py[codz].Will try to reproduce if it still happens in my projects.
My initial search didn't find this issue so I opened another one that should get closed automatically https://github.com/anthropics/claude-code/issues/38301. It seems like Claude Code is paying attention to which file is clicked on in Cursor's file explorer, not which file is actually current in the editor.
Until the VSCode extension fixes its context synchronization:
Workaround 1 — Explicitly reference files and selections:
Instead of relying on the extension to pass your selection/active file, tell Claude directly:
Claude can use the Read tool to get the exact content, bypassing the broken IDE context.
Workaround 2 — Copy selection and paste:
Select code in VS Code → Copy → Paste into Claude Code input. The pasted text appears as a "pasted text" block. This reliably transfers the code content regardless of IDE integration bugs.
Workaround 3 — Use the CLI in VS Code's terminal:
Open VS Code's terminal (
Ctrl+`) and runclaude`. The CLI mode doesn't depend on the extension's IDE integration and can read files directly.Workaround 4 — Use @file references:
In some versions, you can reference files explicitly:
This forces Claude to read the file rather than relying on the extension's context.
Reproducible on latest (2.1.104) — macOS
Confirming this bug still occurs on the latest Claude Code CLI.
Environment:
anthropic.claude-code@2.1.101Repro:
ide_opened_filetag in your context right now? If yes, what path? If no, say 'none'."noneNo
ide_opened_filetag is transmitted even though a file is unambiguously open and the editor tab is visible. This breaks the workflow of having the active editor file auto-attach as context — users now have to@-mention every file manually, which is a significant devex regression.Hi @hackyon-anthropic, I found a hint for why the
ide_selectionbug is happening for me (same reason as for @tymonTe above):In my case it only occurs in files that have brackets in their path, which are used in SvelteKit for dynamic routes such as
/some/route/[param]/+page.svelte. In all other files it is working fine as far as I can tell.Yes same here when handling an astro project with dynamic route like [id].astro file, i think this is causing the issue
Also happens with virtual filesystem documents — seems scheme-related.
VS Code 1.128.0, anthropic.claude-code 2.1.206, murbani.vscode-abap-remote-fs 2.6.4 (ABAP via custom
adt://scheme). Selecting a line in anadt://editor sends noide_selection/ide_opened_fileto the model;file://documents work. The CLI in the integrated terminal does receive the same selection (Copilot too), so the extension appears to filter context tofile://URIs.