Skip to content

Commit 2b25861

Browse files
committed
fix(chord_composer): press Return key to commit raw key sequence
With a previous code change, the context went through a non-composing state while FinishChord() was calling ClearChord() which removes the placeholder input. OnContextUpdate() responded to that intermediate change and cleared raw_sequence when it shouldn't. Skip that OnContextUpdate() event by flipping the sending_chord_ flag.
1 parent 7d9ad77 commit 2b25861

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/rime/gear/chord_composer.cc

+7-5
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ ProcessResult ChordComposer::ProcessKeyEvent(const KeyEvent& key_event) {
126126
if (engine_->context()->get_option("ascii_mode")) {
127127
return kNoop;
128128
}
129-
if (pass_thru_) {
129+
if (sending_chord_) {
130130
return ProcessFunctionKey(key_event);
131131
}
132132
bool is_key_up = key_event.release();
@@ -180,13 +180,13 @@ void ChordComposer::UpdateChord() {
180180
void ChordComposer::FinishChord() {
181181
if (!engine_)
182182
return;
183+
sending_chord_ = true;
183184
string code = SerializeChord();
184185
output_format_.Apply(&code);
185186
ClearChord();
186187

187188
KeySequence key_sequence;
188189
if (key_sequence.Parse(code) && !key_sequence.empty()) {
189-
pass_thru_ = true;
190190
for (const KeyEvent& key : key_sequence) {
191191
if (!engine_->ProcessKey(key)) {
192192
// direct commit
@@ -195,8 +195,8 @@ void ChordComposer::FinishChord() {
195195
raw_sequence_.clear();
196196
}
197197
}
198-
pass_thru_ = false;
199198
}
199+
sending_chord_ = false;
200200
}
201201

202202
void ChordComposer::ClearChord() {
@@ -224,8 +224,10 @@ void ChordComposer::OnContextUpdate(Context* ctx) {
224224
}
225225
else if (composing_) {
226226
composing_ = false;
227-
raw_sequence_.clear();
228-
DLOG(INFO) << "clear raw sequence.";
227+
if (!sending_chord_) {
228+
raw_sequence_.clear();
229+
DLOG(INFO) << "clear raw sequence.";
230+
}
229231
}
230232
}
231233

src/rime/gear/chord_composer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ChordComposer : public Processor {
4444

4545
set<int> pressed_;
4646
set<int> chord_;
47-
bool pass_thru_ = false;
47+
bool sending_chord_ = false;
4848
bool composing_ = false;
4949
string raw_sequence_;
5050
connection update_connection_;

0 commit comments

Comments
 (0)