fix: whitespace-only .gitignore lines no longer match every file - #3462
Conversation
There was a problem hiding this comment.
Notice: It looks like you're using hustcer/deepseek-review, but the CHAT_TOKEN hasn't been configured in your repo's Variables/Secrets. Please ensure this token is set for proper functionality. For step-by-step guidance, refer to the CHAT_TOKEN Config section of README.
0a6883a to
ca99e32
Compare
|
@deepseek review一下,用中文回复 |
@deepseek review it and reply in Chinese |
|
@github-actions review一下,用中文回复 |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused fix correctly handles empty states and includes comprehensive regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes whitespace-only ignore patterns accidentally matching the entire workspace.
Changes:
- Skips matcher generation for empty parsed patterns.
- Adds regression coverage for
.gitignoreand glob matching. - Documents the fix in the changelog.
| File | Description |
|---|---|
script/glob/matcher.lua |
Ignores empty matcher states. |
test/basic/gitignore.lua |
Adds regression and compatibility tests. |
test/basic/init.lua |
Registers the new tests. |
changelog.md |
Records the workspace ignore fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
A
.gitignoreline holding only whitespace made the whole workspace disappear from the languageserver. Git treats such a line as blank and skips it, so the file looks harmless in review, and the
symptom is that every file in the project silently stops resolving.
mt:patterninscript/glob/matcher.luareadstate[1]without checking it was there. Awhitespace-only line leaves the state empty, the pattern compiles to something that matches
everything, and the matcher then ignores the workspace root. This returns
nilfor that stateinstead, which is how the caller already represents "this line contributes no pattern", so the line
is skipped exactly as git skips it.
Changelog entry included, per the repo convention of adding one under Unreleased.
Fixes #3458