[richEditor]修复长按将symbol选中问题

Signed-off-by: z00797037 <zhangzecong@huawei.com>
Change-Id: I0c63f38e2b34fd20809cc0afdc759bbfadbd0634
This commit is contained in:
z00797037 2024-07-21 21:00:14 +08:00
parent ae16f9abdb
commit a07606f2e9
2 changed files with 5 additions and 7 deletions

View File

@ -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;

View File

@ -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;