Skip to content

Commit

Permalink
perf: do not clear result if text length is 0, means @""
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Feb 13, 2024
1 parent 319fc48 commit 34f75ff
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,13 @@ - (void)selectTextTranslate {
[self.eventMonitor getSelectedText:^(NSString *_Nullable text) {
self.actionType = self.eventMonitor.actionType;

// Clear query if text is nil and user don't want to keep the last result.
if (!text && !Configuration.shared.keepPrevResultWhenEmpty) {
text = @"";
/**
Clear query if text is nil and user don't want to keep the last result.
!!!: text may be @"" when no selected text in Chrome, so we need to handle it.
*/
if (text.length == 0) {
text = Configuration.shared.keepPrevResultWhenEmpty ? nil : @"";
}
self.selectedText = [text trim];

Expand Down

0 comments on commit 34f75ff

Please sign in to comment.