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

Merge pull request !38392 from zzc0127/symbol
This commit is contained in:
openharmony_ci 2024-07-21 14:34:32 +00:00 committed by Gitee
commit a135c6b9e5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 5 additions and 7 deletions

View File

@ -6783,10 +6783,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);
}
@ -6795,7 +6793,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) {
@ -6822,10 +6820,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);
@ -7646,7 +7645,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

@ -600,7 +600,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;