add support for replaceAll command
This commit is contained in:
parent
000a81da7f
commit
9a457c8f58
2 changed files with 15 additions and 2 deletions
|
|
@ -698,6 +698,21 @@ ace.Editor = function(renderer, doc) {
|
||||||
this.selection.setSelectionRange(range);
|
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.find = function(needle) {
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
this.$search.set({needle: needle});
|
this.$search.set({needle: needle});
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ ace.Search.SELECTION = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.find = function(doc) {
|
this.find = function(doc) {
|
||||||
var needle = this.$options.needle;
|
|
||||||
if (!this.$options.needle)
|
if (!this.$options.needle)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
@ -42,7 +41,6 @@ ace.Search.SELECTION = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.findAll = function(doc) {
|
this.findAll = function(doc) {
|
||||||
var needle = this.$options.needle;
|
|
||||||
if (!this.$options.needle)
|
if (!this.$options.needle)
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue