Lines 120-126
Link Here
|
120 |
* @throws IllegalStateException if a REPLACE or REPLACE_FIND operation is not preceded by a successful FIND operation |
120 |
* @throws IllegalStateException if a REPLACE or REPLACE_FIND operation is not preceded by a successful FIND operation |
121 |
* @throws PatternSyntaxException if a regular expression has invalid syntax |
121 |
* @throws PatternSyntaxException if a regular expression has invalid syntax |
122 |
*/ |
122 |
*/ |
123 |
private IRegion findReplace(final FindReplaceOperationCode operationCode, int startOffset, String findString, String replaceText, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) throws BadLocationException { |
123 |
private IRegion findReplace(FindReplaceOperationCode operationCode, int startOffset, String findString, String replaceText, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) throws BadLocationException { |
124 |
|
124 |
|
125 |
// Validate option combinations |
125 |
// Validate option combinations |
126 |
Assert.isTrue(!(regExSearch && wholeWord)); |
126 |
Assert.isTrue(!(regExSearch && wholeWord)); |
Lines 155-160
Link Here
|
155 |
if (!regExSearch && !wholeWord) |
155 |
if (!regExSearch && !wholeWord) |
156 |
findString= asRegPattern(findString); |
156 |
findString= asRegPattern(findString); |
157 |
|
157 |
|
|
|
158 |
if (fFindReplaceMatchOffset == startOffset) |
159 |
operationCode= FIND_NEXT; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=80661 |
160 |
|
158 |
fFindReplaceMatchOffset= startOffset; |
161 |
fFindReplaceMatchOffset= startOffset; |
159 |
if (fFindReplaceMatcher != null && fFindReplaceMatcher.pattern().pattern().equals(findString) && fFindReplaceMatcher.pattern().flags() == patternFlags) { |
162 |
if (fFindReplaceMatcher != null && fFindReplaceMatcher.pattern().pattern().equals(findString) && fFindReplaceMatcher.pattern().flags() == patternFlags) { |
160 |
/* |
163 |
/* |
Lines 203-210
Link Here
|
203 |
if (operationCode == REPLACE_FIND_NEXT) |
206 |
if (operationCode == REPLACE_FIND_NEXT) |
204 |
fFindReplaceState= FIND_NEXT; |
207 |
fFindReplaceState= FIND_NEXT; |
205 |
|
208 |
|
206 |
if (found && fFindReplaceMatcher.group().length() > 0) |
209 |
if (found) { |
207 |
return new Region(fFindReplaceMatcher.start(), fFindReplaceMatcher.group().length()); |
210 |
fFindReplaceMatchOffset= fFindReplaceMatcher.start(); |
|
|
211 |
int end= fFindReplaceMatcher.end(); |
212 |
return new Region(fFindReplaceMatchOffset, end - fFindReplaceMatchOffset); |
213 |
} |
208 |
return null; |
214 |
return null; |
209 |
} |
215 |
} |
210 |
|
216 |
|
Lines 212-218
Link Here
|
212 |
boolean found= fFindReplaceMatcher.find(0); |
218 |
boolean found= fFindReplaceMatcher.find(0); |
213 |
int index= -1; |
219 |
int index= -1; |
214 |
int length= -1; |
220 |
int length= -1; |
215 |
while (found && fFindReplaceMatcher.start() + fFindReplaceMatcher.group().length() <= fFindReplaceMatchOffset + 1) { |
221 |
while (found && fFindReplaceMatcher.start() + fFindReplaceMatcher.group().length() <= fFindReplaceMatchOffset) { |
216 |
index= fFindReplaceMatcher.start(); |
222 |
index= fFindReplaceMatcher.start(); |
217 |
length= fFindReplaceMatcher.group().length(); |
223 |
length= fFindReplaceMatcher.group().length(); |
218 |
found= fFindReplaceMatcher.find(index + 1); |
224 |
found= fFindReplaceMatcher.find(index + 1); |