Skip to content

fix: whitespace-only .gitignore lines no longer match every file - #3462

Merged
sumneko merged 4 commits into
LuaLS:masterfrom
cpruijsen:fix/issue-3458
Sep 22, 2026
Merged

sumneko merged 4 commits into
LuaLS:masterfrom
cpruijsen:fix/issue-3458

Conversation

@cpruijsen

Copy link
Copy Markdown
Contributor

A .gitignore line holding only whitespace made the whole workspace disappear from the language
server. 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:pattern in script/glob/matcher.lua read state[1] without checking it was there. A
whitespace-only line leaves the state empty, the pattern compiles to something that matches
everything, and the matcher then ignores the workspace root. This returns nil for that state
instead, 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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sumneko

sumneko commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

@deepseek review一下,用中文回复

@Issues-translate-bot

Copy link
Copy Markdown

Sumneko Lua translate bot


@deepseek review it and reply in Chinese

@sumneko

sumneko commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

@github-actions review一下,用中文回复

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .gitignore and 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.

@sumneko
sumneko merged commit dc578d8 into LuaLS:master Sep 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Line with just a space in gitignore causes whole project to be ignored

4 participants