[BUG] missing ide_selection and wrong ide_opened_file in VSCode extension

Open 💬 48 comments Opened Sep 30, 2025 by pasqoc
💡 Likely answer: A maintainer (hackyon-anthropic, collaborator) responded on this thread — see the highlighted reply below.

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.

View original on GitHub ↗

48 Comments

github-actions[bot] · 9 months ago

Found 1 possible duplicate issue:

  1. 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

pasqo · 9 months ago

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.

oneill1979 · 9 months ago

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.

tarekrached · 9 months ago

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.

tarekrached · 9 months ago

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.

bdmayes-ps · 9 months ago
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.

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.

oneill1979 · 9 months ago

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.

feng-pplx · 9 months ago

+1, seeing this on remote dev, but not local

ykvarts · 9 months ago

seeing same problem, remote dev, large repo, different file types

robinneufeld-relativity · 9 months ago

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?

tymonTe · 8 months ago

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" />

a-gn · 8 months ago

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.toml is 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 same pyproject.toml selection 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).
antonstor · 8 months ago

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
DanTrz · 7 months ago

Same exact issue happening with me

CermakM · 7 months ago

Confirming this is happening to me only in a larger python repository.

hackyon-anthropic collaborator · 7 months ago

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

antonstor · 7 months ago

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

hackyon-anthropic collaborator · 7 months ago

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" />

hackyon-anthropic collaborator · 7 months ago

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" />

a-gn · 7 months ago
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 alt="Image" width="251" height="91" src="https://private-user-images.githubusercontent.com/171081355/523147166-8c1e68b9-f3a6-4342-82fb-c7554016d39f.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjQ5NjcxNDgsIm5iZiI6MTc2NDk2Njg0OCwicGF0aCI6Ii8xNzEwODEzNTUvNTIzMTQ3MTY2LThjMWU2OGI5LWYzYTYtNDM0Mi04MmZiLWM3NTU0MDE2ZDM5Zi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUxMjA1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MTIwNVQyMDM0MDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNTlmYjBjOGM5M2Q2ZDM5ZmQ5ZWUzYTc2YTQ3OWQyOWZmM2JmYTU3ZWMxYjAzOWYxMTRlMDdlOTdhY2I0YzQyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.A2nPZDCbOW4O3wGHCIwpWQv1-W4iy9clRNcy16h-k3o">

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.md is 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.

hackyon-anthropic collaborator · 7 months ago

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.

antonstor · 7 months ago
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.

ericreg · 7 months ago

This is happening to me in a small python repo (4 .py files) 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

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"]
github-actions[bot] · 6 months ago

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.

hackyon-anthropic collaborator · 6 months ago

For everyone who is seeing this, are you using devcontainers or remote workspaces somehow?

DanTrz · 6 months ago
For everyone who is seeing this, are you using devcontainers or remote workspaces somehow?

No

hackyon-anthropic collaborator · 6 months ago

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:

  1. Can you @-mention the file?
  2. If you run claude in an external terminal can you @-mention that file there?
DanTrz · 6 months ago
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: 1. Can you @-mention the file? 2. If you run claude in an external terminal can you @-mention that file there?
  1. No. I cannot @-mention any file.
  2. Never tried. I will try later and let you know
hackyon-anthropic collaborator · 6 months ago

Can you check if those files/patterns are found in .gitignore, .ignore, git/info/exclude, ~/.gitignore_global?

tarekrached · 6 months ago

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" />

Can you check if those files/patterns are found in .gitignore, .ignore, git/info/exclude, ~/.gitignore_global?

None of these files are in any of those - they're all in source control.

hackyon-anthropic collaborator · 6 months ago

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.

tarekrached · 6 months ago
are all your python files under a specific file path compared to other 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.

hackyon-anthropic collaborator · 6 months ago

Can you share the pwd of 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 default

ykvarts · 6 months ago

It 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).

siddhzx · 6 months ago

Unsubscribe

On Thu, Jan 8, 2026 at 12:51 PM Yuriy Kvartsyanyy @.***>
wrote:

ykvarts left a comment (anthropics/claude-code#8451) <https://github.com/anthropics/claude-code/issues/8451#issuecomment-3725204893> It 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). — Reply to this email directly, view it on GitHub <https://github.com/anthropics/claude-code/issues/8451#issuecomment-3725204893>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AY7DCNADJ3SN2YKA4ZRCOE34F2RMNAVCNFSM6AAAAACH3ZNZS2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTOMRVGIYDIOBZGM> . You are receiving this because you are subscribed to this thread.Message ID: @.***>
tarekrached · 6 months ago
Can you share the pwd of 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 default

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_selection works as expected for python files.

0xhardman · 6 months ago

I'm also experiencing this issue on macOS.

Environment

  • OS: macOS 15.7.2 (arm64)
  • Claude Code CLI: 2.1.3
  • IDE: Windsurf / VSCode (both have the extension installed)
  • Extension version: 2.1.4

Observations

  1. The issue appeared after upgrading to Claude Code 2.0+
  2. Reinstalling the VSCode extension temporarily fixed it, but the problem returned
  3. I'm running multiple IDE clients (both Windsurf and VSCode) that connect to the same Claude Code CLI - this might be related?

Current IDE Lock Files

I have multiple lock files in ~/.claude/ide/:

  • VSCode connected to /Users/.../bangkok-sdk
  • Windsurf connected to /Users/.../order_placer
  • Windsurf connected to /Users/.../bangkok-sdk

Perhaps the multiple client connections are causing conflicts with the ide_selection context?

Additional Issue

I also noticed that subagents (spawned via Task tool) auto-deny WebSearch with error:

Error: Permission to use WebSearch has been auto-denied in dontAsk mode.

Even though WebSearch is explicitly allowed in ~/.claude/settings.local.json. Not sure if this is related or a separate bug.

hackyon-anthropic collaborator · 6 months ago

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 --hidden in that directory to see you can see python files in that search? rg is the ripgrep search we use under the hood (same for VSCode too)

helloenjoi · 5 months ago

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

eliezedeck · 4 months ago

+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.

kvet · 4 months ago

Having the same issue with the latest versions of VSCode and Claude Code

a-gn · 4 months ago
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

Note that uv's default .gitignore is:

# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info

# Virtual environments
.venv

So *.py[oc] could be a suspect. I saw the bug in projects that had either this .gitignore or GitHub's, which contains *.py[codz].

Will try to reproduce if it still happens in my projects.

chris-tsongas-mixmailer · 3 months ago

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.

yurukusa · 3 months ago

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:

Look at src/auth/login.ts lines 42-58

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 run claude`. 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:

@src/auth/login.ts What's wrong with the login function?

This forces Claude to read the file rather than relying on the extension's context.

jheyworth · 3 months ago

Reproducible on latest (2.1.104) — macOS

Confirming this bug still occurs on the latest Claude Code CLI.

Environment:

  • Claude Code CLI: 2.1.104 (just updated from 2.1.87)
  • VS Code extension: anthropic.claude-code@2.1.101
  • VS Code: 1.115.0 (arm64)
  • macOS: 26.4.1 (Darwin 25.4.0)

Repro:

  1. Open a file in the editor as a permanent tab (double-click from Explorer)
  2. Focus the Claude Code panel
  3. Ask: "Do you see an ide_opened_file tag in your context right now? If yes, what path? If no, say 'none'."
  4. Response: none

No ide_opened_file tag 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.

cornzz · 1 month ago

Hi @hackyon-anthropic, I found a hint for why the ide_selection bug 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.

SeinlyXz · 8 days ago
Hi @hackyon-anthropic, I found a hint for why the ide_selection bug 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

JanBloudicek · 6 days ago

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 an adt:// editor sends no ide_selection/ide_opened_file to 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 to file:// URIs.