made several changes/ fixes to the search
This commit is contained in:
parent
e1c8930427
commit
b3f5211851
2 changed files with 32 additions and 18 deletions
|
|
@ -811,14 +811,18 @@ var Editor = function(renderer, doc) {
|
|||
this.clearSelection();
|
||||
};
|
||||
|
||||
this.replace = function(replacement) {
|
||||
this.replace = function(replacement, options) {
|
||||
if (options)
|
||||
this.$search.set(options);
|
||||
var range = this.$tryReplace(this.getSelectionRange(), replacement);
|
||||
if (range !== null)
|
||||
this.selection.setSelectionRange(range);
|
||||
this.$updateDesiredColumn();
|
||||
},
|
||||
|
||||
this.replaceAll = function(replacement) {
|
||||
this.replaceAll = function(replacement, options) {
|
||||
if (options)
|
||||
this.$search.set(options);
|
||||
this.clearSelection();
|
||||
this.selection.moveCursorTo(0, 0);
|
||||
|
||||
|
|
@ -845,18 +849,29 @@ var Editor = function(renderer, doc) {
|
|||
}
|
||||
};
|
||||
|
||||
this.find = function(needle) {
|
||||
this.find = function(needle, options) {
|
||||
this.clearSelection();
|
||||
this.$search.set({needle: needle});
|
||||
this.findNext();
|
||||
options = options || {};
|
||||
options.needle = needle;
|
||||
this.$search.set(options);
|
||||
console.log("options: ", JSON.stringify(this.$search.$options));
|
||||
this.$find();
|
||||
},
|
||||
|
||||
this.findNext = function() {
|
||||
this.$find(false);
|
||||
this.findNext = function(options) {
|
||||
options = options || {};
|
||||
if (typeof options.backwards == "undefined")
|
||||
options.backwards = false;
|
||||
this.$search.set(options);
|
||||
this.$find();
|
||||
};
|
||||
|
||||
this.findPrevious = function() {
|
||||
this.$find(true);
|
||||
this.findPrevious = function(options) {
|
||||
options = options || {};
|
||||
if (typeof options.backwards == "undefined")
|
||||
options.backwards = true;
|
||||
this.$search.set(options);
|
||||
this.$find();
|
||||
};
|
||||
|
||||
this.$find = function(backwards) {
|
||||
|
|
@ -864,9 +879,8 @@ var Editor = function(renderer, doc) {
|
|||
this.$search.set({needle: this.doc.getTextRange(this.getSelectionRange())});
|
||||
}
|
||||
|
||||
this.$search.set({
|
||||
backwards: backwards
|
||||
});
|
||||
if (typeof backwards != "undefined")
|
||||
this.$search.set({backwards: backwards});
|
||||
|
||||
var range = this.$search.find(this.doc);
|
||||
if (range) {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ Search.SELECTION = 2;
|
|||
if (this.$options.backwards) {
|
||||
var iterator = this.$backwardMatchIterator(doc);
|
||||
} else {
|
||||
var iterator = this.$forwardMatchIterator(doc);
|
||||
iterator = this.$forwardMatchIterator(doc);
|
||||
}
|
||||
|
||||
var firstRange = null;
|
||||
|
|
@ -50,7 +50,7 @@ Search.SELECTION = 2;
|
|||
if (this.$options.backwards) {
|
||||
var iterator = this.$backwardMatchIterator(doc);
|
||||
} else {
|
||||
var iterator = this.$forwardMatchIterator(doc);
|
||||
iterator = this.$forwardMatchIterator(doc);
|
||||
}
|
||||
|
||||
var ranges = [];
|
||||
|
|
@ -149,7 +149,7 @@ Search.SELECTION = 2;
|
|||
if (this.$options.regExp) {
|
||||
var needle = this.$options.needle;
|
||||
} else {
|
||||
var needle = ace.escapeRegExp(this.$options.needle);
|
||||
needle = ace.escapeRegExp(this.$options.needle);
|
||||
}
|
||||
|
||||
if (this.$options.wholeWord) {
|
||||
|
|
@ -190,7 +190,7 @@ Search.SELECTION = 2;
|
|||
var row = start.row;
|
||||
|
||||
var line = getLine(row);
|
||||
startIndex = start.column;
|
||||
var startIndex = start.column;
|
||||
|
||||
var stop = false;
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ Search.SELECTION = 2;
|
|||
if (row == start.row)
|
||||
stop = true;
|
||||
|
||||
var line = getLine(row);
|
||||
line = getLine(row);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -247,7 +247,7 @@ Search.SELECTION = 2;
|
|||
return;
|
||||
|
||||
row--;
|
||||
var startIndex = 0;
|
||||
startIndex = 0;
|
||||
|
||||
if (row < firstRow) {
|
||||
if (wrap) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue