fix(autocompletion): preserve # in gitignore patterns like *#*##905
Open
syf2211 wants to merge 1 commit into
Open
fix(autocompletion): preserve # in gitignore patterns like *#*##905syf2211 wants to merge 1 commit into
syf2211 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
.gitignorecontains*#*#, 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
ignore_rules.py, only strip text after#when#is preceded by whitespace (inline comment), preserving patterns like*#*#andtest#file.txt.tests/autocompletion/test_ignore_rules.pycovering the regression and inline-comment behavior.Tests
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.