Skip to content

Commit

Permalink
perf: improve display Apple dictionary, do not show query for queryVi…
Browse files Browse the repository at this point in the history
…ewController
  • Loading branch information
tisfeng committed Dec 20, 2023
1 parent 9b8b0e3 commit 68db476
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Easydict/Feature/Service/Apple/AppleDictionary/EZAppleDictionary.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "EZConfiguration.h"
#import "EZWindowManager.h"
#import "NSString+EZUtils.h"
#import "NSString+EZHandleInputText.h"

@implementation EZAppleDictionary

Expand Down Expand Up @@ -634,6 +635,24 @@ - (BOOL)isValidHeadword:(NSString *)headword
*/
BOOL isQueryDictionary = [word shouldQueryDictionaryWithLanguage:language maxWordCount:1];
if (isQueryDictionary) {
// LaTeX == latex
if ([normalizedWord caseInsensitiveCompare:normalizedHeadword] == NSOrderedSame) {
return YES;
}

/**
We need to filter it
queryViewController --> query
*/
if ([word isEnglishWord]) {
NSString *splitWord = [word splitCodeText];
NSString *splitHeadword = [headword splitCodeText];
if (splitWord.wordCount != splitHeadword.wordCount && [splitWord containsString:splitHeadword]) {
return NO;
}
}

return YES;
} else {
if ([normalizedHeadword containsString:normalizedWord]) {
Expand Down

0 comments on commit 68db476

Please sign in to comment.