Created attachment 36177 [details] Fix the sample Fix paragraph text search results start point marking error. ##src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java Each loop of rArray in the searchText method causes beginTextPos and beginCharPos to be reset accordingly. The resulting TextSegment returns invalid data. Such as: Search ${code} in Runs data ["code:${", "code","}"]. The correct result returned should be ### start startRun 0 startText 0 startChar 5 ### end endRun 2 endText 0 endChar 0 But the actual interior only retains the startRun state, and startText, startChar are reset at each loop. startRun 0 startText 0 startChar 0
Would you be able to provide a test case? Something that reads an input docx and that does a searchText call that fails with existing code but that passes with your change. A few existing tests can be found in: https://github.com/apache/poi/blob/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java