Skip to content

Commit

Permalink
[Search] Allow single-character search queries in non-Latin languages
Browse files Browse the repository at this point in the history
Fixes #2012.
  • Loading branch information
kirb committed Dec 17, 2022
1 parent 1329228 commit f1196d5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Zebra/Tabs/Search/ZBSearchTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ - (void)updateSearchResultsForSearchController:(nonnull UISearchController *)sea

if (self->shouldPerformSearching) {
NSString *strippedString = [searchController.searchBar.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

if (strippedString.length <= 1) {

// 0xFF is the final character of the Latin-1 Supplement, effectively allowing single char
// searches to be performed in non-Latin languages. It makes sense to allow searches for a
// single character for languages such as Chinese, Japanese, and Korean, but it comes with
// a performance cost, so we try to balance it out by not allowing it for Latin languages.
if (strippedString.length == 0 || (strippedString.length == 1 && [strippedString characterAtIndex:0] < 0xFF)) {
results = @[];

[resultsController setFilteredResults:results];
Expand Down

0 comments on commit f1196d5

Please sign in to comment.