View | Details | Raw Unified | Return to bug 80661
Collapse All | Expand All

(-)src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java (-4 / +10 lines)
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);
(-)src/org/eclipse/jface/text/TextViewer.java (-3 / +8 lines)
Lines 4222-4230 Link Here
4222
				int length= matchRegion.getLength();
4222
				int length= matchRegion.getLength();
4223
4223
4224
				// Prevents setting of widget selection with line delimiters at beginning or end
4224
				// Prevents setting of widget selection with line delimiters at beginning or end
4225
				char startChar= adapter.charAt(widgetPos);
4225
				boolean borderHasLineDelimiter= false;
4226
				char endChar= adapter.charAt(widgetPos+length-1);
4226
				try {
4227
				boolean borderHasLineDelimiter= startChar == '\n' || startChar == '\r' || endChar == '\n' || endChar == '\r';
4227
					char startChar= adapter.charAt(widgetPos);
4228
					char endChar= adapter.charAt(widgetPos+length-1);
4229
					borderHasLineDelimiter= startChar == '\n' || startChar == '\r' || endChar == '\n' || endChar == '\r';
4230
				} catch (IndexOutOfBoundsException e) {
4231
					// Not a problem at beginning or end of document
4232
				}
4228
				boolean redraws= redraws();
4233
				boolean redraws= redraws();
4229
				if (borderHasLineDelimiter && redraws)
4234
				if (borderHasLineDelimiter && redraws)
4230
					setRedraw(false);
4235
					setRedraw(false);

Return to bug 80661