Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to ignore line endings when matching lines from --exclude-file #1888

Closed
Jackenmen opened this issue Mar 14, 2021 · 4 comments · Fixed by #1889
Closed

Add a way to ignore line endings when matching lines from --exclude-file #1888

Jackenmen opened this issue Mar 14, 2021 · 4 comments · Fixed by #1889
Assignees
Labels

Comments

@Jackenmen
Copy link
Contributor

This can be especially when repository is used on Windows with git's core.autocrlf set to true as then some files can have CRLF line endings locally even though they're checked out into git with LF endings. This mixing can therefore cause codespell to not ignore some lines if the line endings in --exclude-file differ from line endings in the file with spelling issue.

@peternewman
Copy link
Collaborator

Yeah I'd agree, the line ending should be irrelevant within any of our config files (--exclude-file, --ignore-word-list) etc.

@DimitriPapadopoulos
Copy link
Collaborator

DimitriPapadopoulos commented Jan 23, 2024

I'm reopening this because the new rstrip() from #1889 might remove not only newlines but also spaces. We need to make sure everything works as expected.

@DimitriPapadopoulos
Copy link
Collaborator

It seems to be working as expected for me:

$ file exclude-file1.txt exclude-file2.txt test1.txt test2.txt 
exclude-file1.txt: ASCII text
exclude-file2.txt: ASCII text, with CRLF line terminators
test1.txt:         ASCII text
test2.txt:         ASCII text, with CRLF line terminators
$ 
$ codespell test1.txt test2.txt 
test1.txt:1: accepecting ==> accepting
test2.txt:1: accepecting ==> accepting
$ 
$ codespell -x exclude-file1.txt test1.txt test2.txt 
$ 
$ codespell -x exclude-file2.txt test1.txt test2.txt 
$ 

However, the above works whatever spaces we add at the end of any of the above files. It looks like all trailing newlines and spaces are not taken into account when matching lines. Perhaps spaces should be taken into account when matching.

@Jackenmen
Copy link
Contributor Author

I'm pretty sure that was an intentional choice, trailing space is a nightmare to deal with and requiring that the line in ignore file contains that space doesn't seem to actually benefit you in any way since the contents of the line are still identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants