summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authoranaran2012-12-02 13:49:37 (EST)
committer libing wang2012-12-05 09:38:56 (EST)
commitd963d4d8bc15daf004cdabf294fe68bc8ecc9f8b (patch)
treee803cee133755ce1088197b0a914035cd4ad0fea
parentcfeccd40ec194b4ec8d269957eb0ae88cad645e7 (diff)
downloadorg.eclipse.orion.client-d963d4d8bc15daf004cdabf294fe68bc8ecc9f8b.zip
org.eclipse.orion.client-d963d4d8bc15daf004cdabf294fe68bc8ecc9f8b.tar.gz
org.eclipse.orion.client-d963d4d8bc15daf004cdabf294fe68bc8ecc9f8b.tar.bz2
Update bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js
Perform replacement text symbol substitutions when regular expression option is enabled. Tested with Find: localStorage\["(\w+)"\] Replace: localStorage.$1
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js b/bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js
index c0c62d3..1d37424 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js
@@ -371,8 +371,16 @@ orion.TextSearcher = (function() {
end = result.end;
}
}
- editor.setText(newStr, start, end);
- editor.setSelection(start , start + newStr.length, true);
+ if (this._useRegExp) {
+ var newStrWithSubstitutions = editor.getText().substring(start, end).replace(new RegExp(searchStr), newStr);
+ if (newStrWithSubstitutions) {
+ editor.setText(newStrWithSubstitutions, start, end)
+ editor.setSelection(start, start + newStrWithSubstitutions.length, true);
+ }
+ } else {
+ editor.setText(newStr, start, end);
+ editor.setSelection(start, start + newStr.length, true);
+ }
this.endUndo();
if (this._findAfterReplace && searchStr){
this._doFind(searchStr, this.getSearchStartIndex(false), false, this._wrapSearch);