Skip to content

Commit

Permalink
fix: clear query not work when select translate text is empty (#658)
Browse files Browse the repository at this point in the history
* chore(deps): bump rexml in the bundler group across 1 directory (#655)

Bumps the bundler group with 1 update in the / directory: [rexml](https://github.com/ruby/rexml).


Updates `rexml` from 3.3.3 to 3.3.6
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](ruby/rexml@v3.3.3...v3.3.6)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
  dependency-group: bundler
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: clear query not work when select translate text is empty

* fix: rename variables

* fix: do not clear query when input translate by default

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
tisfeng and dependabot[bot] authored Aug 26, 2024
1 parent 85a940c commit 76540d9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ extension Defaults.Keys {
static let adjustPopButtonOrigin = Key<Bool>("EZConfiguration_kAdjustPopButtomOriginKey", default: false)
static let allowCrashLog = Key<Bool>("EZConfiguration_kAllowCrashLogKey", default: true)
static let allowAnalytics = Key<Bool>("EZConfiguration_kAllowAnalyticsKey", default: true)
static let clearInput = Key<Bool>("EZConfiguration_kClearInputKey", default: true)
static let keepPrevResultWhenEmpty = Key<Bool>("EZConfiguration_kKeepPrevResultKey", default: true)

static let clearQueryWhenInputTranslate = Key<Bool>("EZConfiguration_kClearInputKey", default: false)
static let keepPrevResultWhenSelectTranslateTextIsEmpty = Key<Bool>("EZConfiguration_kKeepPrevResultKey", default: true)
static let selectQueryTextWhenWindowActivate = Key<Bool>(
"EZConfiguration_kSelectQueryTextWhenWindowActivate",
default: false
Expand Down
6 changes: 3 additions & 3 deletions Easydict/Swift/Feature/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class Configuration: NSObject {
@DefaultsWrapper(.pinWindowWhenDisplayed) var pinWindowWhenDisplayed
@DefaultsWrapper(.hideMainWindow) var hideMainWindow: Bool

@DefaultsWrapper(.clearInput) var clearInput: Bool
@DefaultsWrapper(.keepPrevResultWhenEmpty) var keepPrevResultWhenEmpty: Bool
@DefaultsWrapper(.clearQueryWhenInputTranslate) var clearInput: Bool
@DefaultsWrapper(.keepPrevResultWhenSelectTranslateTextIsEmpty) var keepPrevResultWhenEmpty: Bool
@DefaultsWrapper(.selectQueryTextWhenWindowActivate) var selectQueryTextWhenWindowActivate: Bool
@DefaultsWrapper(.automaticallyRemoveCodeCommentSymbols) var automaticallyRemoveCodeCommentSymbols: Bool
@DefaultsWrapper(.automaticWordSegmentation) var automaticWordSegmentation: Bool
Expand Down Expand Up @@ -316,7 +316,7 @@ class Configuration: NSObject {
}
.store(in: &cancellables)

Defaults.publisher(.clearInput, options: [])
Defaults.publisher(.clearQueryWhenInputTranslate, options: [])
.removeDuplicates()
.sink { [weak self] _ in
self?.didSetClearInput()
Expand Down
4 changes: 2 additions & 2 deletions Easydict/Swift/View/SettingView/Tabs/TabView/GeneralTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ struct GeneralTab: View {
@Default(.clickQuery) private var clickQuery
@Default(.adjustPopButtonOrigin) private var adjustPopButtonOrigin

@Default(.clearInput) private var clearInput
@Default(.keepPrevResultWhenEmpty) private var keepPrevResultWhenEmpty
@Default(.clearQueryWhenInputTranslate) private var clearInput
@Default(.keepPrevResultWhenSelectTranslateTextIsEmpty) private var keepPrevResultWhenEmpty
@Default(.selectQueryTextWhenWindowActivate) private var selectQueryTextWhenWindowActivate
@Default(.automaticWordSegmentation) var automaticWordSegmentation: Bool
@Default(.automaticallyRemoveCodeCommentSymbols) var automaticallyRemoveCodeCommentSymbols: Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,8 @@ - (void)selectTextTranslate {
!!!: text may be @"" when no selected text in Chrome, so we need to handle it.
*/
if (text.length == 0 && Configuration.shared.keepPrevResultWhenEmpty) {
text = nil;
if (text.length == 0) {
text = Configuration.shared.keepPrevResultWhenEmpty ? nil : @"";
}
self.selectedText = [text trim];

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ GEM
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.7)
rexml (3.3.3)
rexml (3.3.6)
strscan
ruby-macho (2.5.1)
ruby2_keywords (0.0.5)
Expand Down

0 comments on commit 76540d9

Please sign in to comment.