[Tizen] Fix RemoveText issue in text controller 72/277672/2
authorBowon Ryu <bowon.ryu@samsung.com>
Mon, 11 Jul 2022 11:11:23 +0000 (20:11 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Tue, 12 Jul 2022 05:46:30 +0000 (14:46 +0900)
RemoveText() fails to remove text in some cases
before mPreviousNumberOfCharacters of mTextUpdateInfo is updated.

In all text remove situation, it can be removed regardless of the update of this info.
It's same as the previous preedit all remove behavior.

Change-Id: I909b8bcf5edd8466595d93a0d8e5d3ee960a8f50
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali-toolkit/internal/text/text-controller.cpp

index 01a58a9..f96c976 100644 (file)
@@ -2532,6 +2532,7 @@ bool Controller::RemoveText(int                  cursorOffset,
                             UpdateInputStyleType type)
 {
   bool removed = false;
+  bool removeAll = false;
 
   if(NULL == mImpl->mEventData)
   {
@@ -2559,7 +2560,12 @@ bool Controller::RemoveText(int                  cursorOffset,
       numberOfCharacters = currentText.Count() - cursorIndex;
     }
 
-    if(mImpl->mEventData->mPreEditFlag || // If the preedit flag is enabled, it means two (or more) of them came together i.e. when two keys have been pressed at the same time.
+    if((cursorIndex == 0) && (currentText.Count() - numberOfCharacters == 0))
+    {
+      removeAll = true;
+    }
+
+    if(mImpl->mEventData->mPreEditFlag || removeAll || // If the preedit flag is enabled, it means two (or more) of them came together i.e. when two keys have been pressed at the same time.
        ((cursorIndex + numberOfCharacters) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters))
     {
       // Mark the paragraphs to be updated.
@@ -2603,7 +2609,7 @@ bool Controller::RemoveText(int                  cursorOffset,
 
       // If the number of current text and the number of characters to be deleted are same,
       // it means all texts should be removed and all Preedit variables should be initialized.
-      if((currentText.Count() - numberOfCharacters == 0) && (cursorIndex == 0))
+      if(removeAll)
       {
         mImpl->ClearPreEditFlag();
         mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = 0;
@@ -2629,6 +2635,7 @@ bool Controller::RemoveText(int                  cursorOffset,
       }
 
       DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters);
+      removeAll = false;
       removed = true;
     }
   }