!40425 修复RichEditor光标位置不对导致的显示不全问题

Merge pull request !40425 from 姚明/REBug
This commit is contained in:
openharmony_ci 2024-08-15 01:58:38 +00:00 committed by Gitee
commit e943c5a240
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 7 additions and 9 deletions

View File

@ -8051,7 +8051,7 @@ void RichEditorPattern::HandleCursorOnDragEnded(const RefPtr<NotifyDragEvent>& n
if (!isCursorAlwaysDisplayed_) {
TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "In OnDragEnded,"
" the released location is not in the current richEditor, id:%{public}d", host->GetId());
focusHub->LostFocusToViewRoot();
focusHub->LostFocus();
StopTwinkling();
return;
}
@ -8448,19 +8448,17 @@ void RichEditorPattern::HandleOnDragDropTextOperation(const std::string& insertV
CHECK_NULL_VOID(BeforeChangeText(changeValue, record, RecordType::DRAG));
if (isDeleteSelect) {
if (currentPosition < dragRange_.first) {
HandleOnDragInsertValue(insertValue);
InsertValueByOperationType(insertValue, OperationType::DRAG);
dragRange_.first += strLength;
dragRange_.second += strLength;
HandleOnDragDeleteForward();
caretPosition_ += strLength;
} else if (currentPosition > dragRange_.second) {
HandleOnDragInsertValue(insertValue);
InsertValueByOperationType(insertValue, OperationType::DRAG);
int32_t delLength = HandleOnDragDeleteForward();
caretPosition_ -= (delLength - strLength);
caretPosition_ -= delLength;
}
} else {
HandleOnDragInsertValue(insertValue);
caretPosition_ += strLength;
InsertValueByOperationType(insertValue, OperationType::DRAG);
}
AfterChangeText(changeValue);
}
@ -8507,7 +8505,7 @@ void RichEditorPattern::HandleOnDragInsertValue(const std::string& insertValue)
}
record.addText = insertValue;
ClearRedoOperationRecords();
HandleOnDragInsertValueOperation(insertValue);
InsertValueByOperationType(insertValue, OperationType::DRAG);
int32_t length = dragRange_.second - dragRange_.first;
record.afterCaretPosition = record.beforeCaretPosition + length;
record.deleteCaretPostion = dragRange_.first;

View File

@ -707,7 +707,7 @@ HWTEST_F(RichEditorPatternTestNg, HandleCursorOnDragMoved001, TestSize.Level1)
*/
richEditorPattern->isCursorAlwaysDisplayed_ = false;
richEditorPattern->HandleCursorOnDragMoved(notifyDragEvent);
EXPECT_EQ(richEditorPattern->isCursorAlwaysDisplayed_, false);
EXPECT_EQ(richEditorPattern->isCursorAlwaysDisplayed_, true);
}
/**