Regarding WORDSNET-17732, we have completed the work on your issue and concluded to close this issue as ‘Not a Bug’. Please see the following analysis details:
Your case can be reproduced with the following simplified code:
Document doc = new Document(@"consecutive_runs.docx");
doc.Range.Replace("[[[if cn=”lease.hasMonetaryCapOnGuaranty && lease.monetaryCapOnGuarantyPeriod == 0”]]]",
"<!!!!>", new FindReplaceOptions(FindReplaceDirection.Forward));
doc.Range.Replace("<!!!!>", "[[[if cn=”lease.hasMonetaryCapOnGuaranty && lease.monetaryCapOnGuarantyPeriod == 0”]]]"
, new FindReplaceOptions(FindReplaceDirection.Forward));
Actually, for the example above latest version of Aspose.Words does not perform any replacement, so you see runs, which were read from the source.
We had added a feature to escape the ampersand character. Such functionality allows to preserve symbols sequence associated with declared meta-characters as is. So,
“&&” will be changed to
“&” and no occurrences will be found.
You have to implement additional escaping for the ampersand character i.e. replace
“&&” for both pattern and replacement strings.
So, in the latest version, find/replace feature does not change document if no occurrence is found. You can also look at source document and see that output has the same Run count as original. You can call JoinRunsWithSameFormatting method explicitly if you want runs to be joined.