ReplaceText with formatting - bug?

Feb 3, 2015 at 2:18 PM
Hello, I'm playing with DocX and I was trying to replace some text with specific formatting. Yet, unless I'm doing something wrong, this does not seem to work and nothing gets replaced. Stepping through the code I've found that when Paragraph.ReplaceText is called and you loop through the matches the run returned by GetFirstRunEffectedByEdit is not the one corresponding to the matched part of the paragraph's text, but its first run, which having a different formatting is not matched. Thus, ultimately nothing is replaced.

In my test code, I created a dummy DOCX with a couple of paragraphs where the searched word "para" has "Courier New" as its font, and then try replaced it like:
            doc.ReplaceText("para", "para", false, RegexOptions.None,
                new Formatting {FontFamily = new FontFamily("Arial")},
                new Formatting {FontFamily = new FontFamily("Courier New")});
(Here I just wanted to see if the word was matched by replacing its font with Arial. Yet, it would be great if ReplaceText could also match formatting only, whatever the text value is).

Any hint?
Thanks!