| author | anaran | 2012-12-02 13:49:37 (EST) |
|---|---|---|
| committer | libing wang | 2012-12-05 09:38:56 (EST) |
| commit | fef6691cffbbe2ab808d985fcb84feca0f5a8b43 (patch) (side-by-side diff) | |
| tree | e803cee133755ce1088197b0a914035cd4ad0fea | |
| parent | 9883faf36dd0569d96553b2489c9fb5b68574000 (diff) | |
| download | org.eclipse.orion.client-fef6691cffbbe2ab808d985fcb84feca0f5a8b43.zip org.eclipse.orion.client-fef6691cffbbe2ab808d985fcb84feca0f5a8b43.tar.gz org.eclipse.orion.client-fef6691cffbbe2ab808d985fcb84feca0f5a8b43.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.js | 12 |
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); |

