Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfingerl2017-07-01 13:39:07 +0000
committerDani Megert2017-07-13 14:37:20 +0000
commit126cd981c14b7afe5dff9cd865a98b290348637f (patch)
treefbfd76eef55e9a6c27d4c825800d847e12bf0e07 /org.eclipse.text/src/org
parent506916a97c81a0aa96091598addb3970c7acc28a (diff)
downloadeclipse.platform.text-126cd981c14b7afe5dff9cd865a98b290348637f.tar.gz
eclipse.platform.text-126cd981c14b7afe5dff9cd865a98b290348637f.tar.xz
eclipse.platform.text-126cd981c14b7afe5dff9cd865a98b290348637f.zip
Bug 109481 - [find/replace] replace doesn't work when using a regex with
a lookahead or boundary matchers Fixes the bug that matches of a Regular Expression containing lookarounds can't replaced. Change-Id: Ibaf347fbe88b9d9aac14240f67bf5cbb7567e82b Signed-off-by: fingerl <imelflorianingerl@gmail.com>
Diffstat (limited to 'org.eclipse.text/src/org')
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
index d80a2f9cc16..7fc5049fee1 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Cagatay Calli <ccalli@gmail.com> - [find/replace] retain caps when replacing - https://bugs.eclipse.org/bugs/show_bug.cgi?id=28949
* Cagatay Calli <ccalli@gmail.com> - [find/replace] define & fix behavior of retain caps with other escapes and text before \C - https://bugs.eclipse.org/bugs/show_bug.cgi?id=217061
+ * Florian Ingerl <imelflorianingerl@gmail.com> - [find/replace] replace doesn't work when using a regex with a lookahead or boundary matchers - https://bugs.eclipse.org/bugs/show_bug.cgi?id=109481
*******************************************************************************/
package org.eclipse.jface.text;
@@ -194,8 +195,11 @@ public class FindReplaceDocumentAdapter implements CharSequence {
String prevMatch= fFindReplaceMatcher.group();
try {
replaceText= interpretReplaceEscapes(replaceText, prevMatch);
- Matcher replaceTextMatcher= pattern.matcher(prevMatch);
- replaceText= replaceTextMatcher.replaceFirst(replaceText);
+ Matcher replaceTextMatcher= pattern.matcher(this);
+ replaceTextMatcher.find(fFindReplaceMatcher.start());
+ StringBuffer sb= new StringBuffer();
+ replaceTextMatcher.appendReplacement(sb, replaceText);
+ replaceText= sb.substring(fFindReplaceMatcher.start());
} catch (IndexOutOfBoundsException ex) {
throw new PatternSyntaxException(ex.getLocalizedMessage(), replaceText, -1);
}

Back to the top