Skip to content

Commit 102d421

Browse files
authored
feat(chord_composer): finish chord on first release (#828)
add param `chord_composer/finish_chord_on_first_key_release`
1 parent a4ed799 commit 102d421

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/rime/gear/chord_composer.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ ChordComposer::ChordComposer(const Ticket& ticket) : Processor(ticket) {
2727
config->GetBool("chord_composer/use_shift", &use_shift_);
2828
config->GetBool("chord_composer/use_super", &use_super_);
2929
config->GetBool("chord_composer/use_caps", &use_caps_);
30+
config->GetBool("chord_composer/finish_chord_on_first_key_release",
31+
&finish_chord_on_first_key_release_);
3032
config->GetString("speller/delimiter", &delimiter_);
3133
algebra_.Load(config->GetList("chord_composer/algebra"));
3234
output_format_.Load(config->GetList("chord_composer/output_format"));
@@ -104,7 +106,12 @@ ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
104106
editing_chord_ = true;
105107
bool is_key_up = key_event.release();
106108
if (is_key_up) {
107-
if (pressed_.erase(ch) != 0 && pressed_.empty()) {
109+
if (finish_chord_on_first_key_release_) {
110+
if (pressed_.find(ch) != pressed_.end()) {
111+
FinishChord();
112+
pressed_.clear();
113+
}
114+
} else if (pressed_.erase(ch) != 0 && pressed_.empty()) {
108115
FinishChord();
109116
}
110117
} else { // key down

src/rime/gear/chord_composer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ChordComposer : public Processor {
4343
bool use_shift_ = false;
4444
bool use_super_ = false;
4545
bool use_caps_ = false;
46+
bool finish_chord_on_first_key_release_ = false;
4647

4748
set<int> pressed_;
4849
set<int> chord_;

0 commit comments

Comments
 (0)