[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.
Found 1 possible duplicate issue:
- https://github.com/anthropics/claude-code/issues/7221
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
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_selection and ide_opened_file jump 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_selection and ide_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.
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.
Same thing. Details:
- Nothing I do in Python files changes what Claude sees as selected. If I switch to a Python file, the previous selection stays in Claude's UI, if any.
- Everything I do in files of other types is correctly reported in the Claude UI. For example,
pyproject.tomlis correctly handled. - This persists between conversations. If I open a Python file, start a Claude conversation, switch to a
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:
- Claude Code for VSCode version 2.0.35,
- macOS Tahoe 26.1,
- M1 MacBook Air (2020).
Have the same issue. This is pretty disruptive, so I'm surprised this isn't being prioritized higher.
Environment:
- Claude Code for VSCode version 2.0.44
- macOS Tahoe 26.0.1
- Apple M3 Pro
- VS Code v1.106.0
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
It might not just be .gitignore, we also honor the file and search exclusion settings in VSCode:
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
![]()
No it's definitely a bug, see the following:
This is with Claude Code 2.0.59.
When you press @ , can you reference that python file? Do you have any .ignore files 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.
It's something specific to the setup, since it's still working for many other users.
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 .py files) in a dev
container. Does not happening a c++ devcontainer.
Likely irrelevant, but this is my Dockerfile
FROM python:3.13-slim
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies only (no build tools needed)
RUN apt update && apt install --assume-yes \
curl \
git \
openjdk-25-jdk \
uuid-dev \
zsh \
&& apt autoremove -y \
&& apt clean -y \
&& rm -rf /var/lib/apt/lists/*
# Download ANTLR artifacts
RUN cd /usr/local/lib && \
curl -O https://www.antlr.org/download/antlr-4.13.2-complete.jar
# Configure ANTLR
RUN echo 'export CLASSPATH=".:/usr/local/lib/antlr-4.13.2-complete.jar:$CLASSPATH"' >> /etc/profile.d/setClassPath.sh && \
echo '#!/bin/sh -ue' > /usr/bin/antlr && \
echo 'java -jar /usr/local/lib/antlr-4.13.2-complete.jar $@' >> /usr/bin/antlr && \
chmod 755 /usr/bin/antlr && \
ldconfig
# Python configuration
ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
# Shell setup
RUN chsh -s /bin/zsh
COPY ["./zshrc", "/root/.zshrc"]