- Fixed replaceAll
This commit is contained in:
parent
f22fc5a2f5
commit
f6039ddab4
1 changed files with 8 additions and 7 deletions
|
|
@ -886,7 +886,7 @@ var Editor = function(renderer, doc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.replace = function(replacement, options) {
|
this.replace = function(replacement, options) {
|
||||||
if (options)
|
if (options)
|
||||||
this.$search.set(options);
|
this.$search.set(options);
|
||||||
var range = this.$tryReplace(this.getSelectionRange(), replacement);
|
var range = this.$tryReplace(this.getSelectionRange(), replacement);
|
||||||
if (range !== null)
|
if (range !== null)
|
||||||
|
|
@ -895,8 +895,11 @@ var Editor = function(renderer, doc) {
|
||||||
},
|
},
|
||||||
|
|
||||||
this.replaceAll = function(replacement, options) {
|
this.replaceAll = function(replacement, options) {
|
||||||
if (options)
|
if (options) {
|
||||||
|
console.log("Find " + options.needle);
|
||||||
this.$search.set(options);
|
this.$search.set(options);
|
||||||
|
}
|
||||||
|
console.log("Replace " + replacement);
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
this.selection.moveCursorTo(0, 0);
|
this.selection.moveCursorTo(0, 0);
|
||||||
|
|
||||||
|
|
@ -904,11 +907,9 @@ var Editor = function(renderer, doc) {
|
||||||
if (!ranges.length)
|
if (!ranges.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (var i=0; i<ranges.length; i++) {
|
for (var i = ranges.length - 1; i >= 0; --i)
|
||||||
var range = ranges[i];
|
this.$tryReplace(ranges[i], replacement);
|
||||||
this.$tryReplace(range, replacement);
|
this.selection.setSelectionRange(ranges[0]);
|
||||||
}
|
|
||||||
this.selection.setSelectionRange(range);
|
|
||||||
this.$updateDesiredColumn();
|
this.$updateDesiredColumn();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue