File ibus-pinyin-fix-select-words-could-be-cleared.patch of Package ibus-pinyin

diff -Nur ibus-pinyin-1.5.0/src/PYPhoneticEditor.cc ibus-pinyin-1.5.0-new/src/PYPhoneticEditor.cc
--- ibus-pinyin-1.5.0/src/PYPhoneticEditor.cc	2012-08-02 22:22:38.000000000 +0800
+++ ibus-pinyin-1.5.0-new/src/PYPhoneticEditor.cc	2017-03-01 14:07:10.359693690 +0800
@@ -32,7 +32,8 @@
 PhoneticEditor::PhoneticEditor (PinyinProperties & props, Config & config)
     : Editor (props, config),
       m_observer (PinyinObserver(*this)),
-      m_lookup_table (m_config.pageSize ())
+      m_lookup_table (m_config.pageSize ()),
+      m_dont_update_preedit (FALSE)
 {
 }
 
@@ -382,7 +383,18 @@
 void
 PhoneticEditor::reset (void)
 {
+    const String &selected_text = m_context->selectedText ();
+    const String &conversion_text = m_context->conversionText ();
+    const String &rest_text = m_context->restText ();
+
+    if (selected_text.empty () && conversion_text.empty () &&
+        rest_text.empty ())
+        m_dont_update_preedit = TRUE;
+    else
+        m_dont_update_preedit = FALSE;
+
     m_context->reset();
+    m_dont_update_preedit = FALSE;
 }
 
 void
@@ -424,6 +436,9 @@
 void
 PhoneticEditor::updatePreeditText (void)
 {
+    if (m_dont_update_preedit)
+        return;
+
     const String &selected_text = m_context->selectedText ();
     const String &conversion_text = m_context->conversionText ();
     const String &rest_text = m_context->restText ();
diff -Nur ibus-pinyin-1.5.0/src/PYPhoneticEditor.h ibus-pinyin-1.5.0-new/src/PYPhoneticEditor.h
--- ibus-pinyin-1.5.0/src/PYPhoneticEditor.h	2012-08-02 22:22:38.000000000 +0800
+++ ibus-pinyin-1.5.0-new/src/PYPhoneticEditor.h	2017-03-01 14:07:08.035693702 +0800
@@ -88,6 +88,7 @@
     std::unique_ptr<PyZy::InputContext>  m_context;
     PinyinObserver                       m_observer;
     LookupTable                          m_lookup_table;
+    gboolean                             m_dont_update_preedit;
 };
 };
 
openSUSE Build Service is sponsored by