@@ -82,18 +82,18 @@ inline static int get_base_layer_key_code(const KeyEvent& key_event) {
82
82
}
83
83
84
84
ProcessResult ChordComposer::ProcessChordingKey (const KeyEvent& key_event) {
85
- bool chording = !chord_.empty ();
86
85
if (key_event.ctrl () || key_event.alt ()) {
87
86
raw_sequence_.clear ();
88
87
ClearChord ();
89
- return chording ? kAccepted : kNoop ;
88
+ return kNoop ;
90
89
}
91
90
int ch = get_base_layer_key_code (key_event);
92
91
// non chording key
93
92
if (std::find (chording_keys_.begin (),
94
93
chording_keys_.end (),
95
94
KeyEvent{ch, 0 }) == chording_keys_.end ()) {
96
- return chording ? kAccepted : kNoop ;
95
+ ClearChord ();
96
+ return kNoop ;
97
97
}
98
98
// chording key
99
99
bool is_key_up = key_event.release ();
@@ -111,6 +111,10 @@ ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
111
111
return kAccepted ;
112
112
}
113
113
114
+ inline static bool is_composing_text (Context* ctx) {
115
+ return ctx->IsComposing () && ctx->input () != kZeroWidthSpace ;
116
+ }
117
+
114
118
ProcessResult ChordComposer::ProcessKeyEvent (const KeyEvent& key_event) {
115
119
if (engine_->context ()->get_option (" ascii_mode" )) {
116
120
return kNoop ;
@@ -122,7 +126,7 @@ ProcessResult ChordComposer::ProcessKeyEvent(const KeyEvent& key_event) {
122
126
int ch = key_event.keycode ();
123
127
if (!is_key_up && ch >= 0x20 && ch <= 0x7e ) {
124
128
// save raw input
125
- if (!engine_->context ()-> IsComposing ( ) || !raw_sequence_.empty ()) {
129
+ if (!is_composing_text ( engine_->context ()) || !raw_sequence_.empty ()) {
126
130
raw_sequence_.push_back (ch);
127
131
DLOG (INFO) << " update raw sequence: " << raw_sequence_;
128
132
}
@@ -209,7 +213,7 @@ void ChordComposer::ClearChord() {
209
213
}
210
214
211
215
void ChordComposer::OnContextUpdate (Context* ctx) {
212
- if (ctx-> IsComposing () && ctx-> input () != kZeroWidthSpace ) {
216
+ if (is_composing_text ( ctx) ) {
213
217
composing_ = true ;
214
218
}
215
219
else if (composing_) {
0 commit comments