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 bbfd00afc3980eab804ec5467cf016befed1f3e5..03aade919ff1151f8ff1f872fd68c992f2f4002f 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 @@ -3137,21 +3137,12 @@ bool RichEditorPattern::AfterIMEInsertValue(const RefPtr& spanNode, in RichEditorAbstractSpanResult retInfo; retInfo.SetSpanIndex(host->GetChildIndex(spanNode)); retInfo.SetEraseLength(insertValueLength); - retInfo.SetValue(spanNode->GetSpanItem()->content); - auto contentLength = StringUtils::ToWstring(spanNode->GetSpanItem()->content).length(); - if (isCreate) { - auto spanEnd = caretPosition_ + 1; - auto spanStart = spanEnd - static_cast(contentLength); - retInfo.SetSpanRangeStart(spanStart); - retInfo.SetSpanRangeEnd(spanEnd); - retInfo.SetOffsetInSpan(0); - } else { - auto spanEnd = spanNode->GetSpanItem()->position; - auto spanStart = spanEnd - static_cast(contentLength); - retInfo.SetSpanRangeStart(spanStart); - retInfo.SetSpanRangeEnd(spanEnd); - retInfo.SetOffsetInSpan(GetCaretPosition() - retInfo.GetSpanRangeStart()); - } + auto spanItem = spanNode->GetSpanItem(); + retInfo.SetValue(spanItem->content); + auto contentLength = static_cast(StringUtils::ToWstring(spanItem->content).length()); + retInfo.SetSpanRangeStart(spanItem->position - contentLength); + retInfo.SetSpanRangeEnd(spanItem->position); + retInfo.SetOffsetInSpan(caretPosition_ - retInfo.GetSpanRangeStart()); retInfo.SetFontColor(spanNode->GetTextColorValue(Color::BLACK).ColorToString()); retInfo.SetFontSize(spanNode->GetFontSizeValue(Dimension(16.0f, DimensionUnit::VP)).ConvertToVp()); retInfo.SetFontStyle(spanNode->GetItalicFontStyleValue(OHOS::Ace::FontStyle::NORMAL));