diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp index bf55c7cab05..31332adc219 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp @@ -6784,10 +6784,8 @@ void RichEditorPattern::MouseDoubleClickParagraphEnd(int32_t& index) } } -void RichEditorPattern::DoubleClickExcludeSymbol(int32_t& start, int32_t& end) +void RichEditorPattern::AdjustSelectionExcludeSymbol(int32_t& start, int32_t& end) { - bool isDoubleClick = caretUpdateType_ == CaretUpdateType::DOUBLE_CLICK; - CHECK_NULL_VOID(isDoubleClick); AdjustSelectorForSymbol(start, HandleType::FIRST, SelectorAdjustPolicy::EXCLUDE); AdjustSelectorForSymbol(end, HandleType::SECOND, SelectorAdjustPolicy::EXCLUDE); } @@ -6796,7 +6794,7 @@ void RichEditorPattern::InitSelection(const Offset& pos) { int32_t currentPosition = paragraphs_.GetIndex(pos); currentPosition = std::min(currentPosition, GetTextContentLength()); - if (caretUpdateType_ == CaretUpdateType::LONG_PRESSED) { + if (caretUpdateType_ == CaretUpdateType::LONG_PRESSED && !isEditing_) { SelectType selectType = SelectType::NONE; selectType = CheckResult(pos, currentPosition); if (selectType == SelectType::NOT_SELECT) { @@ -6823,10 +6821,11 @@ void RichEditorPattern::InitSelection(const Offset& pos) int32_t nextPosition = currentPosition + GetGraphemeClusterLength(GetWideText(), currentPosition); nextPosition = std::min(nextPosition, GetTextContentLength()); MouseDoubleClickParagraphEnd(currentPosition); - DoubleClickExcludeSymbol(currentPosition, nextPosition); + AdjustSelectionExcludeSymbol(currentPosition, nextPosition); if (!IsCustomSpanInCaretPos(currentPosition, true)) { AdjustWordSelection(currentPosition, nextPosition); } + AdjustSelector(currentPosition, nextPosition); TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "init select [%{public}d--%{public}d]", currentPosition, nextPosition); textSelector_.Update(currentPosition, nextPosition); auto selectedRects = paragraphs_.GetRects(currentPosition, nextPosition); @@ -7647,7 +7646,6 @@ bool RichEditorPattern::AdjustWordSelection(int32_t& start, int32_t& end) start = std::min(aiPosStart + spanStart, GetTextContentLength()); end = std::min(aiPosEnd + spanStart, GetTextContentLength()); TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "get ai selector [%{public}d--%{public}d]", start, end); - AdjustSelector(start, end); return true; } return false; diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.h b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.h index 33bccb5ef02..f995f1d52ea 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.h +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.h @@ -598,7 +598,7 @@ public: } void DumpInfo() override; void MouseDoubleClickParagraphEnd(int32_t& index); - void DoubleClickExcludeSymbol(int32_t& start, int32_t& end); + void AdjustSelectionExcludeSymbol(int32_t& start, int32_t& end); void InitSelection(const Offset& pos); bool HasFocus() const; void OnColorConfigurationUpdate() override;