Bugfix: smart-case does not work when search term contains a space#1108
Merged
koutcher merged 1 commit intojonas:masterfrom May 21, 2021
Merged
Conversation
I.e., `set ignore-case = smart-case` does not work when searching a term that includes the space character, e.g., searching 'foo bar' does not match 'Foo Bar'.
Collaborator
|
LGTM, thanks. |
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.
I found that
set ignore-case = smart-casedoes not work when searching a term that includes the space character, e.g., searching 'foo bar' does not match 'Foo Bar'.This is because the category for space is
UTF8PROC_CATEGORY_ZS, which has the value 23, aka 0x17, or 0b10111, and the smart-case test,utf8_string_contains_uppercase, which callsutf8_string_contains, is using bitwise AND to check the category:So then the space character -- category 0x17 -- matches the uppercase category,
UTF8PROC_CATEGORY_LU = 1. I.e.,0x17 & 1is true.My solution is to change the bitwise AND to the equality operator,
==.This is based on my understanding that the
utf8proccategories are not bitmask values (and thatutf8proc_get_propertyreturns a single value, and not a bitmask), although I could be mistaken (this is my first time examining theutf8proclibrary).This regression occurred in 29524d0.
Oh, and by the way,
tigis such a delight to use! I discovered it when I got a MacBook for work and found out how slowgitkruns outside of Linux, and I haven't usedgitksince --tig's gotta be one of my favorite developer tools. Great work!!