From 71ebcb60b6d8b6a4dd9d02e1def85caef8d9338d Mon Sep 17 00:00:00 2001 From: MohamedRejeb Date: Sun, 7 Apr 2024 20:01:42 +0100 Subject: [PATCH] Fix list items numbering issue --- .../com/mohamedrejeb/richeditor/model/RichTextState.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt index fa92e017..d521e8cb 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt @@ -2321,8 +2321,8 @@ class RichTextState internal constructor( ) visualTransformation = VisualTransformation { _ -> TransformedText( - annotatedString, - OffsetMapping.Identity + text = annotatedString, + offsetMapping = OffsetMapping.Identity ) } styledRichSpanList.addAll(newStyledRichSpanList) @@ -2340,7 +2340,7 @@ class RichTextState internal constructor( private fun checkParagraphsType() { var orderedListNumber = 0 var orderedListStartTextSpanStyle = SpanStyle() - richParagraphList.fastForEachIndexed { _, richParagraph -> + richParagraphList.forEach { richParagraph -> val type = richParagraph.type if (type is OrderedList) { orderedListNumber++ @@ -2348,9 +2348,7 @@ class RichTextState internal constructor( if (orderedListNumber == 1) orderedListStartTextSpanStyle = richParagraph.getFirstNonEmptyChild()?.spanStyle ?: SpanStyle() - if (orderedListNumber == type.number) - - type.number = orderedListNumber + type.number = orderedListNumber type.startTextSpanStyle = orderedListStartTextSpanStyle } else { orderedListNumber = 0