[BUG] Selection context ("N lines selected") not shown for gitignored files 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?
In the VSCode extension's graphical interface, the "N lines selected" indicator does not appear in the prompt box footer when selecting text in a file that is ignored by .gitignore. Selection context is also not passed to Claude when sending a message from such a file.
What Should Happen?
The "N lines selected" indicator should appear and selection context should be passed to Claude regardless of whether the active file is gitignored.
Error Messages/Logs
Steps to Reproduce
- Open a git repository in VS Code (Remote-WSL)
- Open a file that matches a
.gitignorerule (e.g. a.envfile, a build artifact, or any file explicitly ignored) - Select several lines
- Observe the Claude Code prompt box footer — no "N lines selected" indicator appears
- Send a message to Claude — Claude does not receive the selected code
Expected Behavior
"N lines selected" appears in the prompt footer and Claude receives the selection as context.
Actual Behavior
No selection indicator. Claude receives no selection context and reports it cannot see any selected code.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.62 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
Additional Findings (isolation)
Through testing, the following variations were confirmed:
- ✅ Tracked file, clean — selection works
- ✅ Tracked file, unsaved changes (dirty) — selection works
- ✅ Untracked file inside repo directory — selection works
- ❌ Gitignored file — selection does not work
Importantly: when running Claude Code in the integrated terminal and connecting via /ide, the terminal-based Claude can see highlighted lines in gitignored files correctly. This confirms the underlying IDE integration and selection detection are functioning — the bug is specific to the graphical extension UI's handling of gitignored files.
This may suggest the extension's webview is applying an additional gitignore filter before displaying the selection indicator and passing context, independent of (and inconsistent with) the core IDE integration layer. Obviously, there could be another explanation.
Is this a regression?
No — confirmed reproducible on v2.1.49, v2.1.58, and v2.1.61. Likely a longstanding bug.
Last Working Version
Unknown — may never have worked for gitignored files.
Workaround
None known short of temporarily removing the file from .gitignore.
Related Issues
- #8451 (missing ide_selection on Linux/WSL2)
- #14153 (selection context not passed in DevContainer/remote environments)
- #25553 (flaky VS Code IDE integration — selected code context intermittently not detected)
- #10428 (flaky IDE connection)
Environment
- OS: Windows 11, WSL2 (Ubuntu 24.04)
- VS Code Version: 1.109.5 (Remote-WSL)
- Claude Code Extension: v2.1.49, v2.1.58, v2.1.61 (all affected)
- Remote-WSL Extension: v0.104.3
- Architecture: x64
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗