[BUG] VS Code/VSCodium extension treats `!`-re-included (tracked) files as gitignored, suppressing selection context
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?
Disclaimer: This bug report was generated by Claude Code itself after an intense session of debugging this.
The Claude Code extension's .gitignore matcher does not honor negation / re-include
patterns (lines starting with !). Files that git considers tracked (because a broad
ignore rule is followed by a ! re-include) are nonetheless treated by the extension as
ignored, so <ide_selection> context is never sent when you select text in them.
This is distinct from #29433 (closed as "not planned"), which is about genuinely
gitignored files. Here the files are not ignored per git — this is a correctness gap
in how negation patterns are evaluated, causing the extension to diverge from git's own
verdict.
What Should Happen?
The Claude Code extension's .gitignore matcher does honor negation / re-include
patterns (lines starting with !).
The message includes <ide_selection> with the selected lines — same as any tracked file.
The extension should match git's ignore verdict, including ! re-includes.
Actual
The message includes only <ide_opened_file> (the open-file notification). No<ide_selection> / no "N lines selected" indicator. Selection context is silently dropped
for every file under the re-included subtree, with no error or indication of why.
Control cases that confirm it's the negation handling, not file type or location per se:
| File | git status | <ide_selection> sent? |
|----------------------------------------|--------------|-------------------------|
| ./root-file.yaml (no ignore match) | tracked | ✅ yes |
| ./root-file.php (no ignore match) | tracked | ✅ yes |
| src/app/code/.../Bar.php (re-included)| tracked | ❌ no |
| src/app/code/.../Baz.txt (re-included)| tracked | ❌ no |
File type is irrelevant; the discriminator is solely whether the path sits under a
broadly-ignored-then-!-re-included subtree.
Error Messages/Logs
Steps to Reproduce
- In a repo, create a
.gitignorethat broadly ignores a subtree but re-includes part of it:
``gitignore``
/src/*
!/src/app
/src/app/*
!/src/app/code
- Create a tracked file under the re-included path, e.g.
src/app/code/Foo/Bar.php.
- Confirm git treats it as tracked / not ignored:
``console``
$ git check-ignore -v src/app/code/Foo/Bar.php
# (no output, exit 1 → NOT ignored)
- In the editor, open that file, select a few lines, and send a message to Claude Code.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.177 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
Workaround
Set "claudeCode.respectGitIgnore": false in workspace settings. This restores
selection sharing throughout the re-included subtree. (Not mentioned in #29433.)
Suggested fix
Use git's own ignore evaluation (e.g. git check-ignore) or a matcher that fully
implements .gitignore negation/precedence rules, rather than a simplified matcher that
stops at the first matching ignore pattern and ignores subsequent ! re-includes.
Related
- #29433 — selection context not shown for gitignored files (closed, not planned).
This report is the negation/re-include correctness case, which #29433 does not cover.