@@ -757,7 +757,8 @@ TextRange getParagraphRange()
757757 /// <param name="range">The range to be replaced</param>
758758 /// <param name="text">The text to replace with</param>
759759 /// <param name="semantics">Controls how undo operations are coalesced and view selections updated</param>"
760- public void ReplaceText ( ITextDocumentView view , TextRange range , string text , EditSemantics semantics )
760+ /// <param name="styleToUse">The style to use for the added text (optional)</param>
761+ public void ReplaceText ( ITextDocumentView view , TextRange range , string text , EditSemantics semantics , IStyle styleToUse = null )
761762 {
762763 // Convert text to utf32
763764 Slice < int > codePoints ;
@@ -771,7 +772,7 @@ public void ReplaceText(ITextDocumentView view, TextRange range, string text, Ed
771772 }
772773
773774 // Do the work
774- ReplaceText ( view , range , codePoints , semantics ) ;
775+ ReplaceText ( view , range , codePoints , semantics , styleToUse ) ;
775776 }
776777
777778 /// <summary>
@@ -781,7 +782,8 @@ public void ReplaceText(ITextDocumentView view, TextRange range, string text, Ed
781782 /// <param name="range">The range to be replaced</param>
782783 /// <param name="codePoints">The text to replace with</param>
783784 /// <param name="semantics">Controls how undo operations are coalesced and view selections updated</param>"
784- public void ReplaceText ( ITextDocumentView view , TextRange range , Slice < int > codePoints , EditSemantics semantics )
785+ /// <param name="styleToUse">The style to use for the added text (optional)</param>
786+ public void ReplaceText ( ITextDocumentView view , TextRange range , Slice < int > codePoints , EditSemantics semantics , IStyle styleToUse = null )
785787 {
786788 // Check range is valid
787789 if ( range . Minimum < 0 || range . Maximum > this . Length )
@@ -802,7 +804,12 @@ public void ReplaceText(ITextDocumentView view, TextRange range, Slice<int> code
802804 codePoints = codePoints . SubSlice ( 0 , breakPos ) ;
803805 }
804806
805- ReplaceTextInternal ( view , range , new StyledText ( codePoints ) , semantics , - 1 ) ;
807+ var styledText = new StyledText ( codePoints ) ;
808+ if ( styledText != null )
809+ {
810+ styledText . ApplyStyle ( 0 , styledText . Length , styleToUse ) ;
811+ }
812+ ReplaceTextInternal ( view , range , styledText , semantics , - 1 ) ;
806813 }
807814
808815 /// <summary>
0 commit comments