remove duplicated candidates
authorPeng Wu <alexepico@gmail.com>
Tue, 8 Nov 2011 05:14:34 +0000 (13:14 +0800)
committerPeng Wu <alexepico@gmail.com>
Thu, 22 Dec 2011 04:23:15 +0000 (12:23 +0800)
src/PYPPhoneticEditor.cc

index e79e492..b5903ae 100644 (file)
@@ -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);