highlight last search result when searchbox is focused

This commit is contained in:
nightwing 2013-04-16 22:24:40 +04:00
commit 689ebf8b48

View file

@ -122,9 +122,11 @@ var SearchBox = function(editor, range, showReplaceForm) {
});
event.addListener(this.searchInput, "focus", function() {
_this.activeInput = _this.searchInput;
_this.searchInput.value && _this.highlight();
});
event.addListener(this.replaceInput, "focus", function() {
_this.activeInput = _this.replaceInput;
_this.searchInput.value && _this.highlight();
});
};
@ -199,6 +201,10 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.find(false, false);
};
this.highlight = function(re) {
this.editor.session.highlight(re || this.editor.$search.$options.re);
this.editor.renderer.updateBackMarkers()
};
this.find = function(skipCurrent, backwards) {
var range = this.editor.find(this.searchInput.value, {
skipCurrent: skipCurrent,
@ -209,7 +215,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
wholeWord: this.wholeWordOption.checked
});
dom.setCssClass(this.searchBox, "ace_nomatch", !range && this.searchInput.value);
this.editor.session.highlight(this.editor.$search.$options.re);
this.highlight();
};
this.findNext = function() {
this.find(true, false);