- // deleted text is within the same line. (merge lines could be needed if the line separator character is deleted)
-
- // Line which contains the characters to be deleted.
- LineLayoutInfo& lineLayout( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndicesBegin.mLineIndex ) );
-
- // Remove the characters from the line layout info. It returns whether the current line can be merged with the next one.
- RemoveCharactersFromLineInfo( relayoutData,
- numberOfCharacters,
- mergeWords,
- mergeLines,
- textInfoIndicesBegin,
- textInfoIndicesEnd,
- textInfoMergeIndicesBegin,
- textInfoMergeIndicesEnd,
- lineLayout,
- removedTextActorsFromBegin,
- removedTextActorsFromEnd );
+ // deleted text is within the same paragraph. (merge paragraphs could be needed if the paragraph separator character is deleted)
+
+ // Paragraph which contains the characters to be deleted.
+ ParagraphLayoutInfo& paragraphLayout( *( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + textInfoIndicesBegin.mParagraphIndex ) );
+
+ // Remove the characters from the text and the styles.
+ const std::size_t firstCharacterIndex = textInfoIndicesBegin.mCharacterParagraphIndex;
+ const std::size_t lastCharacterIndex = textInfoIndicesEnd.mCharacterParagraphIndex + 1u;
+
+ paragraphLayout.mText.Remove( firstCharacterIndex, lastCharacterIndex - firstCharacterIndex );
+
+ for( Vector<TextStyle*>::Iterator it = paragraphLayout.mTextStyles.Begin() + firstCharacterIndex,
+ endIt = paragraphLayout.mTextStyles.Begin() + lastCharacterIndex;
+ it != endIt;
+ ++it )
+ {
+ delete *it;
+ }
+ paragraphLayout.mTextStyles.Erase( paragraphLayout.mTextStyles.Begin() + firstCharacterIndex,
+ paragraphLayout.mTextStyles.Begin() + lastCharacterIndex );
+
+ // Remove the characters from the paragraph layout info. It returns whether the current paragraph can be merged with the next one.
+ RemoveCharactersFromParagraphInfo( relayoutData,
+ numberOfCharacters,
+ mergeWords,
+ mergeParagraphs,
+ textInfoIndicesBegin,
+ textInfoIndicesEnd,
+ textInfoMergeIndicesBegin,
+ textInfoMergeIndicesEnd,
+ paragraphLayout,
+ removedTextActorsFromBegin,
+ removedTextActorsFromEnd );