Bugfix: smart-case does not work when search term contains a space #1108
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-case
does 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 & 1
is true.My solution is to change the bitwise AND to the equality operator,
==
.This is based on my understanding that the
utf8proc
categories are not bitmask values (and thatutf8proc_get_property
returns a single value, and not a bitmask), although I could be mistaken (this is my first time examining theutf8proc
library).This regression occurred in 29524d0.
Oh, and by the way,
tig
is such a delight to use! I discovered it when I got a MacBook for work and found out how slowgitk
runs outside of Linux, and I haven't usedgitk
since --tig
's gotta be one of my favorite developer tools. Great work!!