Skip to content

Commit cc983d5

Browse files
committed
fix(chord_composer): commit raw input with uppercase letters
1 parent 94cf479 commit cc983d5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/rime/gear/chord_composer.cc

+9-5
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ inline static int get_base_layer_key_code(const KeyEvent& key_event) {
8282
}
8383

8484
ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
85-
bool chording = !chord_.empty();
8685
if (key_event.ctrl() || key_event.alt()) {
8786
raw_sequence_.clear();
8887
ClearChord();
89-
return chording ? kAccepted : kNoop;
88+
return kNoop;
9089
}
9190
int ch = get_base_layer_key_code(key_event);
9291
// non chording key
9392
if (std::find(chording_keys_.begin(),
9493
chording_keys_.end(),
9594
KeyEvent{ch, 0}) == chording_keys_.end()) {
96-
return chording ? kAccepted : kNoop;
95+
ClearChord();
96+
return kNoop;
9797
}
9898
// chording key
9999
bool is_key_up = key_event.release();
@@ -111,6 +111,10 @@ ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
111111
return kAccepted;
112112
}
113113

114+
inline static bool is_composing_text(Context* ctx) {
115+
return ctx->IsComposing() && ctx->input() != kZeroWidthSpace;
116+
}
117+
114118
ProcessResult ChordComposer::ProcessKeyEvent(const KeyEvent& key_event) {
115119
if (engine_->context()->get_option("ascii_mode")) {
116120
return kNoop;
@@ -122,7 +126,7 @@ ProcessResult ChordComposer::ProcessKeyEvent(const KeyEvent& key_event) {
122126
int ch = key_event.keycode();
123127
if (!is_key_up && ch >= 0x20 && ch <= 0x7e) {
124128
// save raw input
125-
if (!engine_->context()->IsComposing() || !raw_sequence_.empty()) {
129+
if (!is_composing_text(engine_->context()) || !raw_sequence_.empty()) {
126130
raw_sequence_.push_back(ch);
127131
DLOG(INFO) << "update raw sequence: " << raw_sequence_;
128132
}
@@ -209,7 +213,7 @@ void ChordComposer::ClearChord() {
209213
}
210214

211215
void ChordComposer::OnContextUpdate(Context* ctx) {
212-
if (ctx->IsComposing() && ctx->input() != kZeroWidthSpace) {
216+
if (is_composing_text(ctx)) {
213217
composing_ = true;
214218
}
215219
else if (composing_) {

0 commit comments

Comments
 (0)