From a07606f2e950bdeb7a742eb8784aaa7f6b79ad82 Mon Sep 17 00:00:00 2001 From: z00797037 Date: Sun, 21 Jul 2024 21:00:14 +0800 Subject: [PATCH] =?UTF-8?q?[richEditor]=E4=BF=AE=E5=A4=8D=E9=95=BF?= =?UTF-8?q?=E6=8C=89=E5=B0=86symbol=E9=80=89=E4=B8=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z00797037 Change-Id: I0c63f38e2b34fd20809cc0afdc759bbfadbd0634 --- .../pattern/rich_editor/rich_editor_pattern.cpp | 10 ++++------ .../pattern/rich_editor/rich_editor_pattern.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) 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;