add support for replaceAll command

This commit is contained in:
Fabian Jakobs 2010-04-28 17:52:32 +02:00
commit 9a457c8f58
2 changed files with 15 additions and 2 deletions

View file

@ -698,6 +698,21 @@ ace.Editor = function(renderer, doc) {
this.selection.setSelectionRange(range);
},
this.replaceAll = function(replacement) {
this.clearSelection();
this.selection.moveCursorTo(0, 0);
var ranges = this.$search.findAll(this.doc);
if (!ranges.length)
return;
for (var i=0; i<ranges.length; i++) {
var range = ranges[i];
range.end = this.doc.replace(range, replacement);
}
this.selection.setSelectionRange(range);
},
this.find = function(needle) {
this.clearSelection();
this.$search.set({needle: needle});

View file

@ -22,7 +22,6 @@ ace.Search.SELECTION = 2;
};
this.find = function(doc) {
var needle = this.$options.needle;
if (!this.$options.needle)
return null;
@ -42,7 +41,6 @@ ace.Search.SELECTION = 2;
};
this.findAll = function(doc) {
var needle = this.$options.needle;
if (!this.$options.needle)
return [];