Skip to content

fix(autocompletion): preserve # in gitignore patterns like *#*##905

Open
syf2211 wants to merge 1 commit into
mistralai:mainfrom
syf2211:fix/gitignore-hash-in-pattern
Open

fix(autocompletion): preserve # in gitignore patterns like *#*##905
syf2211 wants to merge 1 commit into
mistralai:mainfrom
syf2211:fix/gitignore-hash-in-pattern

Conversation

@syf2211

@syf2211 syf2211 commented Jul 15, 2026

Copy link
Copy Markdown

Summary

Fix gitignore parsing so patterns containing # (e.g. Emacs autosave *#*#) are not truncated into *, which was causing the file indexer to ignore every file and break @ filepath autocompletion.

Motivation

Fixes #887. When .gitignore contains *#*#, the parser treated the first # as an inline comment delimiter and reduced the pattern to *, matching all files. The file indexer then returned zero entries, so @ autocompletion showed no suggestions.

Changes

  • In ignore_rules.py, only strip text after # when # is preceded by whitespace (inline comment), preserving patterns like *#*# and test#file.txt.
  • Add unit tests in tests/autocompletion/test_ignore_rules.py covering the regression and inline-comment behavior.

Tests

uv run pytest tests/autocompletion/test_ignore_rules.py -v
uv run ruff check vibe/core/autocompletion/file_indexer/ignore_rules.py tests/autocompletion/test_ignore_rules.py

All tests pass (2/2).

Notes

Inline comments with whitespace before # (e.g. *.log # build artifacts) continue to be stripped, matching the prior behavior for comment-style lines.

Only treat # as an inline comment when preceded by whitespace, matching
git's gitignore parsing. Fixes filepath @ autocompletion returning no
suggestions when .gitignore contains Emacs autosave patterns.

Fixes mistralai#887
@syf2211
syf2211 requested a review from a team as a code owner July 15, 2026 06:05
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.

bug: .gitignore pattern *#*# is interpreted as * (ignore all)

1 participant