From 79b34abeecf8b75f434140ba991a9eed65c4a5db Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Sun, 7 Feb 2021 20:36:44 +0800 Subject: [PATCH] fix(chord_composer): should clear raw input after committing text --- src/rime/gear/chord_composer.cc | 8 +++++--- src/rime/gear/chord_composer.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rime/gear/chord_composer.cc b/src/rime/gear/chord_composer.cc index 432161d473..f2cfa1f357 100644 --- a/src/rime/gear/chord_composer.cc +++ b/src/rime/gear/chord_composer.cc @@ -102,6 +102,7 @@ ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) { return kNoop; } // chording key + editing_chord_ = true; bool is_key_up = key_event.release(); if (is_key_up) { if (pressed_.erase(ch) != 0 && pressed_.empty()) { @@ -114,6 +115,7 @@ ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) { if (updated) UpdateChord(); } + editing_chord_ = false; return kAccepted; } @@ -180,13 +182,13 @@ void ChordComposer::UpdateChord() { void ChordComposer::FinishChord() { if (!engine_) return; - sending_chord_ = true; string code = SerializeChord(); output_format_.Apply(&code); ClearChord(); KeySequence key_sequence; if (key_sequence.Parse(code) && !key_sequence.empty()) { + sending_chord_ = true; for (const KeyEvent& key : key_sequence) { if (!engine_->ProcessKey(key)) { // direct commit @@ -195,8 +197,8 @@ void ChordComposer::FinishChord() { raw_sequence_.clear(); } } + sending_chord_ = false; } - sending_chord_ = false; } void ChordComposer::ClearChord() { @@ -224,7 +226,7 @@ void ChordComposer::OnContextUpdate(Context* ctx) { } else if (composing_) { composing_ = false; - if (!sending_chord_) { + if (!editing_chord_ || sending_chord_) { raw_sequence_.clear(); DLOG(INFO) << "clear raw sequence."; } diff --git a/src/rime/gear/chord_composer.h b/src/rime/gear/chord_composer.h index 21d2e89a70..4afa20c036 100644 --- a/src/rime/gear/chord_composer.h +++ b/src/rime/gear/chord_composer.h @@ -44,6 +44,7 @@ class ChordComposer : public Processor { set pressed_; set chord_; + bool editing_chord_ = false; bool sending_chord_ = false; bool composing_ = false; string raw_sequence_;