From 4052c696561ff06e74029cd1ec43355295e15e8c Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 8 Nov 2011 13:14:34 +0800 Subject: remove duplicated candidates --- src/PYPPhoneticEditor.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/PYPPhoneticEditor.cc') diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc index e79e492..b5903ae 100644 --- a/src/PYPPhoneticEditor.cc +++ b/src/PYPPhoneticEditor.cc @@ -190,11 +190,11 @@ LibPinyinPhoneticEditor::fillLookupTableByPage (void) if (need_nr == 0) return FALSE; + String first_candidate, candidate; for (guint i = filled_nr; i < filled_nr + need_nr; i++) { phrase_token_t *token = &g_array_index (m_candidates, phrase_token_t, i); - String first_candidate, candidate; if (null_token == *token) { /* show the rest of guessed sentence after the cursor. */ String buffer; @@ -216,6 +216,13 @@ LibPinyinPhoneticEditor::fillLookupTableByPage (void) pinyin_translate_token(m_instance, *token, &word); candidate = word; + /* remove duplicated candidates */ + if (candidate == first_candidate) { + g_array_remove_index (m_candidates, i); + --i; + continue; + } + /* show get candidates. */ if (G_UNLIKELY (!m_props.modeSimp ())) { /* Traditional Chinese */ candidate.truncate (0); -- cgit