From c2e1912687bf89c6b0d8bb9529998f775e95ea51 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 6 Jun 2018 17:17:42 +0800 Subject: re-factor updatePreeditText method --- src/PYPPinyinEditor.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/PYPPinyinEditor.cc') diff --git a/src/PYPPinyinEditor.cc b/src/PYPPinyinEditor.cc index 14b6832..ab26b55 100644 --- a/src/PYPPinyinEditor.cc +++ b/src/PYPPinyinEditor.cc @@ -233,15 +233,16 @@ void PinyinEditor::updatePreeditText () { /* preedit text = guessed sentence + un-parsed pinyin text */ - if (G_UNLIKELY (m_text.empty ())) { + if (G_UNLIKELY (m_text.empty () || m_candidates.empty () )) { hidePreeditText (); return; } m_buffer.clear (); - char *sentence = NULL; - pinyin_get_sentence (m_instance, 0, &sentence); - if (sentence) { + + EnhancedCandidate & candidate = m_candidates[0]; + String sentence = candidate.m_display_string; + if (CANDIDATE_NBEST_MATCH == candidate.m_candidate_type) { if (m_props.modeSimp ()) { m_buffer<